<template>
  <frame-view>
    <!-- 状态栏 -->
    <status-bar></status-bar>
    <!-- 标题栏 -->
    <title-bar
      :titleProp="this.deviceName"
      :pageTypeProp="1"
      @clickGoBack="closeDevicePage"
    />
    <!-- 故障提示条 -->
    <fault-view
      :faultListPro="this.faultList"
      :darkModePro="this.darkMode"
      :isSpreadedScreenPro="this.getScreenSpreaded"
      :deviceTypePro="this.deviceType"
      :clickablePro="getFaultViewClickable"
      :styleTypePro="getFaultViewStyleType"
    >
    </fault-view>
    <scroll-view>
      <first-page-margin :deviceTypePro="this.deviceType">
        <!-- 产品图片和公司LOGO -->
        <product-image-view :darkModeProp="darkMode"> </product-image-view>
        <!-- 测试，要删除 -->
        <!-- <vue-text
          value="遥襟甫畅，逸兴遄飞。爽籁发而清风生，纤歌凝而白云遏。睢园绿竹，气凌彭泽之樽；邺水朱华，光照临川之笔。四美具，二难并。穷睇眄于中天，极娱游于暇日。天高地迥，觉宇宙之无穷；兴尽悲来，识盈虚之有数。望长安于日下，目吴会于云间。地势极而南溟深，天柱高而北辰远。关山难越，谁悲失路之人？萍水相逢，尽是他乡之客。"
          style="width: 200px"
          :row="2"
        /> -->
        <!-- 设备状态卡片 -->
        <StateView
          :deviceTypePro="this.deviceType"
          :darkModePro="this.darkMode"
          :languagePro="this.language"
          :powerPro="this.isPowerOn"
          :leftStatePro="getStateTitle"
          :showPowerBtnPro="false"
          @clickPower="clickPower"
        >
        </StateView>
        <card-divider></card-divider>
        <!-- 按钮组：翻盖、翻圈、小冲、大冲 -->
        <ButtonRow
          :borderRadiusTypePro="3"
          :showDisablePro="this.isFirstLineBtnsUnable"
        >
          <MyButton
            :titlePro="$t('btnTitle.cover')"
            :btnImgPro="getCoverImg"
            :disablePro="this.isCoverUnable"
            :isOnPro="this.cover"
            @click="clickCover"
            @clickDisable="clickCoverDisable"
          ></MyButton>
          <MyButton
            :titlePro="$t('btnTitle.ring')"
            :btnImgPro="getRingImg"
            :disablePro="this.isRingUnable"
            :isOnPro="this.ring"
            @click="clickRing"
            @clickDisable="clickRingDisable"
          ></MyButton>
          <MyButton
            :titlePro="$t('btnTitle.smallFlush')"
            :btnImgPro="getSmallFlushImg"
            :disablePro="this.isSmallFlushUnable"
            :isOnPro="this.smallFlush"
            @click="clickSmallFlush"
            @clickDisable="clickSmallFlushDisable"
          ></MyButton>
          <MyButton
            :titlePro="$t('btnTitle.flush')"
            :btnImgPro="getFlushImg"
            :disablePro="this.isBigFlushUnable"
            :isOnPro="this.flush"
            @click="clickFlush"
            @clickDisable="clickFlushDisable"
          ></MyButton>
        </ButtonRow>
        <div class="collapseContainer">
          <div class="mainCard">
            <!-- 清洗模式按钮组：臀洗模式、妇洗模式、助便强洗 this.isModeBtnsUnable -->

            <ButtonRow
              :borderRadiusTypePro="1"
              :showDisablePro="this.isModeBtnsUnable"
            >
              <MyButton
                :titlePro="$t('btnTitle.hipMode')"
                :btnImgPro="getHipModeImg"
                :disablePro="this.getModeUnable"
                :isOnPro="this.hipMode && !this.autoHipMode"
                @click="clickHipMode"
                @clickDisable="clickHipModeDisable"
              ></MyButton>
              <MyButton
                :titlePro="$t('btnTitle.womanMode')"
                :btnImgPro="getWomanModeImg"
                :disablePro="this.getModeUnable"
                :isOnPro="this.womanMode && !this.autoWomanMode"
                @click="clickWomanMode"
                @clickDisable="clickWomanModeDisable"
              ></MyButton>
              <MyButton
                :titlePro="$t('btnTitle.strongMode')"
                :btnImgPro="getStrongModeImg"
                :disablePro="this.getModeUnable"
                :isOnPro="this.strongMode"
                @click="clickStrongMode"
                @clickDisable="clickStrongModeDisable"
              ></MyButton>
              <!-- <MyButton
                :titlePro="$t('btnTitle.sitWash')"
                :btnImgPro="getSitWashModeImg"
                :disablePro="this.getModeUnable"
                :isOnPro="this.sitWashMode"
                @click="clickSitWashMode"
                @clickDisable="clickSitWashModeDisable"
              >
              </MyButton> -->
            </ButtonRow>

            <!-- 清洗模式按钮组：自动臀洗、自动妇洗、暖风 -->
            <div :style="getWashModeContainerStyle" ref="lightTreatModeBtnId">
              <ButtonRow
                :showDisablePro="this.isModeBtnsUnable"
                :borderRadiusTypePro="
                  this.seatStatus && this.isWashMode ? 0 : 2
                "
              >
                <MyButton
                  :titlePro="$t('btnTitle.autoHipMode')"
                  :btnImgPro="getAutoHipModeImg"
                  :disablePro="this.getModeUnable"
                  :isOnPro="this.autoHipMode"
                  @click="clickAutoHipMode"
                  @clickDisable="clickAutoHipModeDisable"
                ></MyButton>
                <MyButton
                  :titlePro="$t('btnTitle.autoWomanMode')"
                  :btnImgPro="getAutoWomanModeImg"
                  :disablePro="this.getModeUnable"
                  :isOnPro="this.autoWomanMode"
                  @click="clickAutoWomanMode"
                  @clickDisable="clickAutoWomanModeDisable"
                ></MyButton>
                <MyButton
                  :titlePro="$t('btnTitle.warmWind')"
                  :btnImgPro="getWarmWindModeImg"
                  :disablePro="this.getWindDisable"
                  :isOnPro="
                    this.warmWindMode &&
                    !this.autoHipMode &&
                    !this.autoWomanMode
                  "
                  @click="clickWarmWindMode"
                  @clickDisable="clickWarmWindModeDisable"
                ></MyButton>
                <!-- <MyButton
                  :darkModePro="this.darkMode"
                  :titlePro="getLightTreatModeBtnTitle"
                  :btnImgPro="getLightTreatModeImg"
                  :disablePro="this.getLightTreatUnable"
                  :isOnPro="
                    this.redLightMode || this.blueLightMode || this.mixLightMode
                  "
                  :showArrowPro="true"
                  :arrowUpPro="this.lightTreatModeSetDialogVisible"
                  @click="clickLightTreatMode"
                  @clickDisable="clickLightTreatModeDisable"
                >
                </MyButton> -->
              </ButtonRow>
            </div>

            <!-- 折叠区 -->
            <div
              class="collapseContent"
              v-show="
                this.online &&
                this.seatStatus &&
                (this.isWashMode || this.warmWindMode) &&
                this.showMoreList
              "
            >
              <!-- 折叠区：移动按摩(助便模式下)、宽幅强洗(臀洗模式下)、移动按摩(妇洗模式下)、移动按摩(舒适坐浴模式下)、暖风移动(暖风模式下) -->
              <SwitchButton
                :titleProp="$t('btnTitle.moveWash')"
                :showPro="this.strongMode ? 'visible' : 'gone'"
                :isOnProp="this.moveWash"
                :showDisablePro="getStrongModeMoveWashDisable"
                @clickDisable="clickMoveWashDisable"
                @switchValueChanged="moveWashChangeForStrongMode"
              ></SwitchButton>
              <SwitchButton
                :titleProp="$t('btnTitle.wideWash')"
                :showPro="this.hipMode ? 'visible' : 'gone'"
                :isOnProp="this.wideWash"
                :showDisablePro="getStrongModeMoveWashDisable"
                @clickDisable="clickMoveWashDisable"
                @switchValueChanged="wideWashChange"
              ></SwitchButton>
              <SwitchButton
                :titleProp="$t('btnTitle.moveWash')"
                :showPro="this.womanMode ? 'visible' : 'gone'"
                :isOnProp="this.moveWash"
                :showDisablePro="getStrongModeMoveWashDisable"
                @clickDisable="clickMoveWashDisable"
                @switchValueChanged="moveWashChange"
              ></SwitchButton>
              <SwitchButton
                :titleProp="$t('btnTitle.moveWash')"
                :showPro="this.sitWashMode ? 'visible' : 'gone'"
                :isOnProp="this.moveWash"
                :showDisablePro="getStrongModeMoveWashDisable"
                @clickDisable="clickMoveWashDisable"
                @switchValueChanged="moveWashChangeForSitWashMode"
              ></SwitchButton>
              <SwitchButton
                :titleProp="$t('btnTitle.warmMove')"
                :showPro="'gone'"
                :isOnProp="this.warmMove"
                :showDisablePro="false"
                @clickDisable="clickMoveWashDisable"
                @switchValueChanged="warmMoveChangeForSitWashMode"
              ></SwitchButton>
              <!-- :showPro="this.warmWindMode ? 'visible' : 'gone'" -->
              <!-- 折叠区：幅度设置（宽幅强洗专用） -->
              <SlideView
                :titleProp="$t('btnTitle.range')"
                :deviceTypePro="this.deviceType"
                :darkModePro="this.darkMode"
                :languagePro="this.language"
                :disablePro="isRangeUnable"
                :disableBgPro="false"
                :borderRadiusTypePro="0"
                :visiblePro="this.hipMode ? 'visible' : 'gone'"
                :slideValueProp="moveRangeValue"
                :slideDataProp="getRangeSlideData"
                @sliderValueChanged="sendRangeSlideValue"
                @showDisableClick="notWideWashUnableRange"
              />
              <!--折叠区：水压设置 -->
              <SlideView
                :titleProp="$t('btnTitle.waterPrressure')"
                :deviceTypePro="this.deviceType"
                :darkModePro="this.darkMode"
                :languagePro="this.language"
                :disablePro="isWaterPressUnable"
                :disableBgPro="false"
                :borderRadiusTypePro="0"
                :slideValueProp="waterPressureValue"
                :slideDataProp="getWaterPressureSlideData"
                @sliderValueChanged="sendWaterPresssureSlideValue"
                @showDisableClick="warmWindUnableWaterPress"
                :visiblePro="
                  this.hipMode ||
                  this.womanMode ||
                  this.strongMode ||
                  this.autoHipMode ||
                  this.autoWomanMode ||
                  this.sitWashMode
                    ? 'visible'
                    : 'gone'
                "
              />
              <!-- 折叠区：喷嘴设置 -->
              <SlideView
                :titleProp="$t('btnTitle.spray')"
                :deviceTypePro="this.deviceType"
                :darkModePro="this.darkMode"
                :languagePro="this.language"
                :disablePro="isSpraySliderUnable"
                :disableBgPro="false"
                :borderRadiusTypePro="0"
                :slideValueProp="sprayPositionValue"
                :slideDataProp="getSprayPositionSlideData"
                @sliderValueChanged="sendSprayPositionSlideValue"
                @showDisableClick="wideWashUnableNozzlePos"
                :visiblePro="
                  this.hipMode ||
                  this.womanMode ||
                  this.autoHipMode ||
                  this.autoWomanMode ||
                  this.sitWashMode ||
                  this.strongMode
                    ? 'visible'
                    : 'gone'
                "
              />
            </div>
            <!-- 展开折叠区按钮 -->
            <OpenMoreButton
              :titlePro="getmoreModeTitle"
              :arrowImgPro="getMoreArrowImg"
              :showPro="this.seatStatus && this.isWashMode ? 'visible' : 'gone'"
              @clickButton="clickMoreList"
            >
            </OpenMoreButton>
            <CardDivider></CardDivider>
            <!-- 水温设置 -->
            <SlideView
              :titleProp="$t('btnTitle.waterTemp')"
              :deviceTypePro="this.deviceType"
              :darkModePro="this.darkMode"
              :languagePro="this.language"
              :disablePro="this.seasonTempOpen === 1"
              :slideValueProp="waterTemperatureValue"
              :slideDataProp="getWaterTemperatureSlideData"
              @sliderValueChanged="sendWaterTemperatureSlideValue"
              @showDisableClick="tempSensorUnableWaterTemp"
            />
            <CardDivider></CardDivider>
            <!-- 座温设置 -->
            <SlideView
              :titleProp="$t('btnTitle.seatTemp')"
              :deviceTypePro="this.deviceType"
              :darkModePro="this.darkMode"
              :languagePro="this.language"
              :disablePro="this.seasonTempOpen === 1"
              :slideValueProp="this.seatTemperatureValue"
              :slideDataProp="getSeatTemperatureSlideData"
              @sliderValueChanged="sendSeatTemperatureSlideValue"
              @showDisableClick="tempSensorUnableSeatTemp"
            />
            <CardDivider></CardDivider>
            <!-- 风温设置 -->
            <SlideView
              :titleProp="$t('btnTitle.windTemp')"
              :deviceTypePro="this.deviceType"
              :darkModePro="this.darkMode"
              :languagePro="this.language"
              :slideValueProp="this.windTemperatureValue"
              :slideDataProp="getWindTemperatureSlideData"
              @sliderValueChanged="sendWindTemperatureSlideValue"
            />
            <CardDivider></CardDivider>
            <!-- 风速设置 -->
            <!-- <SlideView
              :titleProp="$t('btnTitle.windSpeed')"
              :deviceTypePro="this.deviceType"
              :darkModePro="this.darkMode"
              :languagePro="this.language"
              :slideValueProp="windSpeedValue"
              :slideDataProp="getWindSpeedSlideData"
              @sliderValueChanged="sendWindSpeedSlideValue"
            />
            <CardDivider></CardDivider> -->
            <!-- 卡片按钮组（小屏幕一排双卡片）魔力泡、喷嘴自洁 -->
            <div>
              <small-card-container>
                <small-card-button
                  :enableViewProp="getMagicBubbleEnable"
                  :isOnProp="this.magicBubble"
                  :titleProp="$t('btnTitle.magicBubble')"
                  :imgStrProp="getMagicalBubbleImg"
                  @click="clickMagicalBubble"
                ></small-card-button>
                <small-card-divider />
                <small-card-button
                  :enableViewProp="getSprayCleanEnable"
                  :isOnProp="this.sprayWash"
                  :titleProp="$t('btnTitle.sprayWash')"
                  :imgStrProp="getSprayWashImg"
                  @click="clickSprayWash"
                ></small-card-button>
              </small-card-container>
            </div>
            <CardDivider></CardDivider>

            <!-- 设备耗材：发泡剂、阻垢滤芯 -->
            <FirstPageCard>
              <FirstPageCardMargin>
                <CardItemTitleView
                  :titlePro="$t('foam.equipmentConsumables')"
                ></CardItemTitleView>
                <!-- <CardItemStateView
                  :titlePro="$t('foam.title')"
                  :stateValuePro="
                    $t('btnTitle.leftHow', { state: this.getFoamState })
                  "
                  :darkModePro="this.darkMode"
                  @click="gotoFoamPage"
                >
                </CardItemStateView> -->
                <!-- <FirstPageCardDivideLine></FirstPageCardDivideLine> -->

                <!-- <CardItemDoubleLineStateView
                  :titlePro="$t('btnTitle.filterElement')"
                  :subtitlePro="
                    $t('btnTitle.useHours', { hour: this.filterLeftTime })
                  "
                  :stateValuePro="
                    $t('btnTitle.leftPer', { state: this.filterLeftPer })
                  "
                  @click="gotoFilterPage"
                >
                </CardItemDoubleLineStateView> -->
                <FirstPageCardDivideLine></FirstPageCardDivideLine>
                <CardItemStateView
                  :titlePro="$t('btnTitle.filterElement1')"
                  :stateValuePro="
                    $t('btnTitle.leftPer', { state: this.filterLeftPer })
                  "
                  :darkModePro="this.darkMode"
                  @click="gotoFilterPage"
                >
                </CardItemStateView>
                <CardDivider :heightPro="8"></CardDivider>
              </FirstPageCardMargin>
            </FirstPageCard>

            <!-- 功能设置按钮 -->
            <card-divider></card-divider>
            <FuncSettingCard :darkMode="this.darkMode"></FuncSettingCard>
            <card-divider
              :heightPro="8"
              v-show="!this.isAiInstall"
            ></card-divider>
            <!-- 售后服务 -->
            <after-sale-view v-show="!this.isAiInstall"></after-sale-view>
          </div>
        </div>
      </first-page-margin>
    </scroll-view>
    <!-- 用户1对话框 -->
    <dialog-container
      :visiblePro="user1DialogShow"
      :visible.sync="user1DialogShow"
      :deviceTypePro="this.deviceType"
    >
      <div class="mainPageUserDialog">
        <div class="titleContainer">
          <div class="title">{{ $t("btnTitle.user1") }}</div>
        </div>
        <div class="funcBtnContainer" @click="clickUseUser1Param">
          <div class="title">{{ $t("userDialog.use") }}</div>
          <div class="content">
            {{ $t("userDialog.useInfo") }}
          </div>
        </div>
        <div class="lineContainer"></div>
        <div class="funcBtnContainer" @click="clickSaveUser1Param">
          <div class="title">{{ $t("userDialog.save") }}</div>
          <div class="content">
            {{ $t("userDialog.saveInfo") }}
          </div>
        </div>
        <div class="cancelBtnContainer">
          <div class="cancelBtn">{{ $t("userDialog.cancel") }}</div>
        </div>
      </div>
    </dialog-container>
    <!-- 用户2对话框 -->
    <dialog-container
      :visiblePro="user2DialogShow"
      :visible.sync="user2DialogShow"
      :deviceTypePro="this.deviceType"
    >
      <div class="mainPageUserDialog">
        <div class="titleContainer">
          <div class="title">{{ $t("btnTitle.user2") }}</div>
        </div>
        <div class="funcBtnContainer" @click="clickUseUser2Param">
          <div class="title">{{ $t("userDialog.use") }}</div>
          <div class="content">
            {{ $t("userDialog.useInfo") }}
          </div>
        </div>
        <div class="lineContainer"></div>
        <div class="funcBtnContainer" @click="clickSaveUser2Param">
          <div class="title">{{ $t("userDialog.save") }}</div>
          <div class="content">
            {{ $t("userDialog.saveInfo") }}
          </div>
        </div>
        <div class="cancelBtnContainer">
          <div class="cancelBtn">{{ $t("userDialog.cancel") }}</div>
        </div>
      </div>
    </dialog-container>
    <!-- 自动模式选择对话框 -->
    <auto-mode-set-dialog
      v-model="lightTreatModeSetDialogVisible"
      :listData="getLightTreatModeDialogItemList"
      :selectedIndexPro="getLightTreatModeDialogSelectItem"
      :attachViewWidth="getLightTreatModeDialogAttachViewWidth()"
      :attachViewTopPro="lightTreatModeDialogAttachViewTop"
      :darkMode="darkMode"
      :deviceTypePro="this.deviceType"
      @clickMyItem="hasSelectedLightTreatMode"
      @cancel="cancelLightTreatModeSelect()"
    >
    </auto-mode-set-dialog>
  </frame-view>
</template>

<script>
import "../assets/css/index.css";
import "../assets/css/frame.css";
import {
  refreshWebView,
  modifyTitleBar,
  setChangeTitleStyle,
  overrideTitleBarRightBtn,
  setgoSettingListener,
  setMessageVisible,
  getStatusBarHeight,
  setStatuBarHeightListener,
  sendProperty,
  setPropertiesListener,
  setNavigationVisible,
  getDevCacheAll,
  setDevCacheAllListener,
  getProperty,
  toast,
  debugLog,
  userLog,
  getDarkMode,
  finishDeviceActivity,
  deleteDevice,
  modifyDeviceName,
  modifyDeviceNameById,
  modifyRoomName,
  getDeviceInfo,
  setDeviceInfoListener,
  getDevInfoAll,
  setDevInfoAllListener,
  setDeleteDeviceCallBack,
  setModifyDeviceNameCallBack,
  setModifyDeviceNameByIdCallBack,
  setModifyRoomCallBack,
  setSendPropertyListener,
  setRequestPropertyListener,
  setOnResumeListener,
  setOnPauseListener,
  createRule,
  setCreateRuleListener,
  deleteRule,
  setDeleteRuleListener,
  getRules,
  setGetRuleListener,
  controlRuleActive,
  setControlRuleActiveListener,
  jumpToSetting,
  setJumpToSettingListener,
  getSwitchProperties,
  setRequestSwitchPropertiesListener,
  getControlProperties,
  setRequestControlPropertiesListener,
  getStatusProperties,
  setRequestStatusPropertiesListener,
  getGearProperties,
  setRequestGearPropertiesListener,
  getWarnEventProperties,
  setRequestWarnEventPropertiesListener,
  getFaultEventProperties,
  setRequestFaultEventPropertiesListener,
  isScreenSpreaded,
  getCurrentTime,
  getAppLanguage,
  sendPropertyWithCallback,
  dataChange,
  getAiInstall,
} from "../assets/js/device.js";

import {
  WIDTH_PHONE,
  PHONE_RATIO,
  WIDTH_SPREADED,
  SPREADED_RATIO,
  WIDTH_PAD_PORTRAIT,
  PAD_PORTRAIT_RATIO,
  WIDTH_PAD_LANDSCAPE,
  PAD_LANDSCAPE_RATIO,
  WIDTH_STANDARD,
  SPREADED_SCREEN_RATIO,
  selectWidth,
  flexibleWidth,
  flexibleHeight,
  screenWidth,
  screenHeight,
  screenDpr,
  screenType,
  screenDescription,
  isIOS,
  isSpreadOn,
  screenSize,
  getSecondPageMarginStyle,
  getSecondPageStyle,
  getDialogFlexAlign,
  getDialogStyle,
  getSingleButtonStyle,
  setScreenResizeListener,
  itemWidth,
} from "../assets/js/flexible.js";

import Const from "../const/const.js";
import eventBus from "../assets/js/eventbus.js";

import FrameView from "./custom/frame/FrameView.vue";
import FirstPageMargin from "./custom/frame/first/FirstPageMargin.vue";
import FirstPageCard from "./custom/frame/first/FirstPageCard.vue";
import FirstPageCardMargin from "./custom/frame/first/FirstPageCardMargin.vue";
import FirstPageCardDivideLine from "./custom/frame/first/FirstPageCardDivideLine.vue";
import ScrollView from "./custom/frame/ScrollView.vue";
import StatusBar from "./custom/frame/StatusBar.vue";
import TitleBar from "./custom/frame/TitleBar.vue";
import ProductImageView from "./custom/ProductImageView.vue";

import StateView from "./custom/StateView.vue";
import ButtonCard from "./custom/ButtonCard.vue";
import ButtonRow from "./custom/ButtonRow.vue";
import MyButton from "./custom/MyButton.vue";
import SmallCardContainer from "./custom/SmallCardContainer.vue";
import SmallCardButton from "./custom/SmallCardButton.vue";
import SmallCardDivider from "./custom/SmallCardDivider.vue";
import MenuDialog from "./custom/MenuDialog.vue";
import ProgressBar from "./custom/ProgressView.vue";
import LoadingView from "./custom/LoadingView.vue";
import MyLoadingView from "./custom/MyLoadingView.vue";
import ListRatioDialog from "./custom/ListRatioDialog.vue";
import MyMintSlide from "./custom/slide/Slide.vue";
import CardDivider from "./custom/CardDivider.vue";
import FaultView from "./custom/FaultView.vue";
import MySwitch from "./custom/MySwitch.vue";
import AfterSaleView from "./custom/AfterSaleView.vue";
import DialogContainer from "./custom/dialog/DialogContainer.vue";
import AutoModeSetDialog from "./custom/ListSetDialog.vue";
import OpenMoreButton from "./custom/OpenMoreButton.vue";
import SwitchButton from "./custom/SwitchButton.vue";
import SlideView from "./custom/SlideView.vue";
import FuncSettingCard from "./custom/setting/FuncSettingCard.vue";
import CardItemStateView from "./custom/setting/CardItemStateView.vue";
import CardItemDoubleLineStateView from "./custom/setting/CardItemDoubleLineStateView.vue";
import CardItemTitleView from "./custom/setting/CardItemTitleView.vue";
import TitleView from "./custom/TitleView.vue";

import VueText from "./custom/VueText.vue";

window.sendUser1Enable = (res) => {
  let data = dataChange(res);
  console.log("MainPage ", "发送‘使用用户1’指令的回调：res = ", data);
  sendUser1EnableListener(data);
};
window.sendUser1Save = (res) => {
  let data = dataChange(res);
  console.log("MainPage ", "发送‘保存用户1’指令的回调：res = ", data);
  sendUser1SaveListener(data);
};
window.sendUser2Enable = (res) => {
  let data = dataChange(res);
  console.log("MainPage ", "发送‘使用用户2’指令的回调：res = ", data);
  sendUser2EnableListener(data);
};
window.sendUser2Save = (res) => {
  let data = dataChange(res);
  console.log("MainPage ", "发送‘保存用户2’指令的回调：res = ", data);
  sendUser2SaveListener(data);
};
var sendUser1EnableListener;
var sendUser1SaveListener;
var sendUser2EnableListener;
var sendUser2SaveListener;

export default {
  name: "MainPage",
  components: {
    FrameView,
    FirstPageCard,
    FirstPageCardMargin,
    FirstPageCardDivideLine,
    ScrollView,
    FirstPageMargin,
    ProductImageView,
    MenuDialog,
    ProgressBar,
    LoadingView,
    MyLoadingView,
    ListRatioDialog,
    MyMintSlide,
    StatusBar,
    TitleBar,
    CardDivider,
    FaultView,
    StateView,
    MySwitch,
    ButtonCard,
    ButtonRow,
    MyButton,
    SmallCardContainer,
    SmallCardButton,
    SmallCardDivider,
    AfterSaleView,
    DialogContainer,
    AutoModeSetDialog,
    OpenMoreButton,
    SwitchButton,
    SlideView,
    FuncSettingCard,
    CardItemStateView,
    CardItemDoubleLineStateView,
    CardItemTitleView,
    TitleView,
    VueText,
  },
  data() {
    // toast(1000, "data");
    return {
      netWorkOnLine: navigator.onLine, //网络是否在线

      showMoreList: false, //“展开更多”当前是否展开

      power: false, //开关
      darkMode: "light", //暗黑/白天模式
      language: "en", //app当前的语言，默认是简体中文
      deviceType: 1, //设备屏幕类型：1-android手机，2-android Pad竖屏，3-android Pad横屏，4-android折叠屏，101-iPhone，102-iPad
      screenWidth: 0, //屏幕宽度
      screenHeight: 0, //屏幕高度

      //被动状态
      online: true, //设备是否在线
      deviceName: "", //"九牧i4Pro智能马桶", //"Intelligent Toilet", //设备名
      deviceNameOldItfc: "", //暂存旧接口获取的设备名称（作为比较用）
      deviceNameNewItfc: "", //暂存新接口获取的设备名称（作为比较用）
      firstIntoPage: true, //第一次进入页面的标志
      deviceId: "",
      roomName: "未选择", //设备放置的房间

      seatStatus: false, //是否着座
      workStatus: "1", //工作状态(互斥) 0:上电初始化 1:停止待机 2:停止进行中 3:喷嘴自洁 4:烘干 5:臀洗 6:妇洗 7:畅洗 8:坐浴 9:强弱按摩 10:宽幅清洗 11:臀洗移动 12:妇洗移动 13:畅洗移动 14:坐浴移动 15:自动臀洗 16:自动烘干

      //独立按钮
      cover: false, //马桶盖当前状态（开或关）
      coverCache: false, //翻盖缓存
      ring: false, //马桶圈当前状态（开或关）
      ringCache: false, //翻圈缓存
      coverPlateStatus: false, //翻盖中（开盖中或关盖中）
      seatRingStatus: false, //翻圈中（开圈中或关圈中）
      coverOpening: false, //开盖中
      coverClosing: false, //关盖中
      ringOpening: false, //开圈中
      ringClosing: false, //关圈中

      flush: false, //大冲
      smallFlush: false, //小冲
      injectorClean: false, //喷嘴清洁
      wideWash: false, //宽幅清洗(在臀洗模式下才能开启)
      moveWash: false, //移动按摩(只在妇洗模式、助便强洗模式、坐浴模式下才能开启)
      warmMove: false, //暖风移动(只在暖风模式下才能开启)
      magicBubble: false, //魔力泡(独立按钮)

      //模式(这四个模式是互斥的，开启其中之一，其他三个按钮必须关闭)
      autoWomanMode: false, //自动妇洗模式
      autoHipMode: false, //自动臀洗模式
      hipMode: false, //臀洗模式
      womanMode: false, //妇洗模式
      warmWindMode: false, //暖风模式
      strongMode: false, //助便强洗模式
      sitWashMode: false, //舒适坐浴模式
      lightTreatMode: false, //光照理疗模式
      redLightMode: false, //红光模式（光照理疗）
      blueLightMode: false, //蓝光模式（光照理疗）
      mixLightMode: false, //混合模式（光照理疗）

      sprayWash: false, //喷嘴自洁
      sprayDisassemble: false, //喷嘴拆卸
      deodorize: 0, //光触媒除臭模式 0-关闭 1-定点模式 2-定时模式 3-自动模式
      dredgeMode: false, //疏通模式
      fillingBox: false, //加液盒开关
      waterEffluent: false, //清洗时是否已经出水
      waterLevel: false, //水位：0-未加满 1-已加满

      // autoModeHipWash: false, //自动模式的臀洗阶段
      // autoModeWideWash: false, //自动模式的宽幅强洗阶段
      // autoModeWomanWash: false, //自动模式的妇洗阶段
      // autoModeMoveWash: false, //自动模式的移动按摩阶段
      // autoModeWarnWind: false, //自动模式的烘干阶段

      // modeList: [{ selected: false, title: "" }],

      moveRangeValue: 0, //幅度，滑条上的百分比
      sprayPositionValue: 0, //喷嘴位置，滑条上的百分比
      oldSprayPositionValue: 0, //上一次喷嘴位置，滑条上的百分比
      waterPressureValue: 0, //水压，滑条上的百分比
      waterTemperatureValue: 0, //水温，滑条上的百分比
      oldWaterTemperatureValue: 0, //上一次水温，滑条上的百分比
      seatTemperatureValue: 0, //座温，滑条上的百分比
      oldSeatTemperatureValue: 0, //上一次座温，滑条上的百分比
      windTemperatureValue: 0, //风温，滑条上的百分比
      windSpeedValue: 50, //风速，滑条上的百分比
      moreDialogVisible: false,

      womanNozzlePos: 1, //妇洗喷嘴位置，设备端传来的值1-5
      hipNozzlePosition: 1, //臀洗喷嘴位置，设备端传来的值1-5
      womanWaterGage: 1, //妇洗水压，设备端传来的值1-5
      hipWaterGage: 1, //臀洗水压，设备端传来的值1-5

      seasonTempOpen: false, //四季温感是否打开

      hasClick: false,
      moreModeTitle: "展开更多",

      statusBarHeight: 20, //状态栏高度
      statusBarColor: "transparent",
      materialHeight: 0, //耗材高度

      //设置选项
      redLightDuration: 1, //红光光照时长：1-5分钟 2-10分钟 3-15分钟 4-20分钟
      blueLightDuration: 1, //蓝光光照时长：1-5分钟 2-10分钟 3-15分钟 4-20分钟
      deodorizationDuration: 0, //除臭时长：0-5分钟 1-10分钟 2-15分钟 3-20分钟 4-25分钟 5-30分钟
      regularDeodorization: 0, //定时除臭（每隔一段时间除臭）：0-12关闭 1-24小时 2-72小时 3-96小时 4-120小时 5-144小时
      deodorizationHour: 0, //定点除臭时钟（定义每天的几点除臭，要与订单除臭分钟配合使用）：0-23
      deodorizationMin: 0, //定点除臭分钟（定义每天的某个时点的第几分钟除臭，要与电动除臭时钟配合使用）：0-59

      uiLockTimer: "", //定时器：发送指令后，锁定UI不更新3秒钟，避免状态错误
      uiIsLocking: false, //锁：发送指令后，锁定UI不更新3秒钟，避免状态错误

      // flushClickLockTimer: "", //定时器：暖风结束时，开启一个定时器，在规定时间内不能冲水
      // flushClickLocking: false, //锁：冲水锁，只有这个锁打开了，才能启动冲水

      //按服务缓存数据
      stopData: null, //一键关闭服务：0-取消
      seatStatusData: null, //着座状态服务：0-未着座 1-已着座
      toiletModeData: null, //马桶模式服务数据：0-待机模式 1-臀洗模式 2-臀洗自动 3-妇洗模式 100-妇洗自动模式 101-儿童模式 102-坐浴模式 103-畅洗模式 104-烘干模式
      wideWashData: null, //宽幅强洗开关服务
      moveWashData: null, //移动按摩开关服务
      smallflushSwitchData: null, //小冲开关服务
      bigflushSwitchData: null, //大冲开关服务
      seatRingData: null, //开圈开关服务
      filpSwitchData: null, //开盖开关服务
      windGearData: null, //风温档位服务
      waterGearData: null, //水温档位服务
      seatGearData: null, //座温档位服务
      filterElementData: null, //滤芯耗材服务
      tStatusData: null, //马桶状态服务
      toiletStatusData: null, //马桶当前状态服务
      controlData: null, //control服务数据
      toiletGearData: null, //马桶额外档位服务
      deviceAlarmData: null, //设备告警服务
      faultDetectionData: null, //设备故障服务
      settingData: null, //设置参数服务

      // //缓存数据
      // cache:{

      // },

      //故障信息
      faultList: {
        faultCode: 0, //发送故障的code，0代表无故障
        warnCode: 0, //发生告警的code，0代表无告警
        remindCode: 0, //发生提醒的code, 0代表无提醒(优先级最低)
        faults: { 0: { title: "", reason: "", solution: [] } },
        warns: { 0: { title: "", reason: "", solution: [] } },
        reminds: { 0: { title: "", reason: "", solution: [] } },
      },
      // isShowFault: false, //是否显示故障提示条

      //场景联动
      sceneBathHeaterSwitch: false, //浴霸联动开关
      sceneTowelSwitch: false, //毛巾架联动开关
      sceneBathHeaterLock: false, //浴霸联动开关锁
      sceneTowelLock: false, //毛巾架联动开关锁

      //联动设备
      bathHeaterId: null, //浴霸
      towelId: null, //毛巾架

      //联动规则列表
      rules: null,

      bubbleTimer: "", //定时器：发泡开启后延时60s,才能再次开启魔力泡
      bubbleIsLocking: false, //锁：发泡开启后延时60s,才能再次开启魔力泡

      sprayWashTimer: "", //定时器：喷嘴自洁完成后延时10s,才能再次开启
      sprayWashIsLocking: false, //锁：喷嘴自洁完成后延时10s,才能再次开启

      isLoadAllDataByService: false, //加载所有服务的数据

      //发泡剂
      foamLeftState: 0, //发泡剂剩余状态：0-正常(默认)，1-低(不足)，2-高(充足），3-未加(无)
      //滤芯
      filterLeftTime: 30, //滤芯预计可用时间数（小时）
      filterLeftPer: 20, //滤芯剩余百分比
      filterLevel: 101, //滤芯等级：101-（滤芯等级101，对应的滤芯总使用时间为300小时） 102-（滤芯等级102，对应的滤芯总使用时间为200小时）

      //用户
      user1DialogShow: false, //用户1对话框是否显示
      user2DialogShow: false, //用户2对话框是否显示
      user1: 0, //用户1操作状态 0-未操作 1-启用 2-保存
      user2: 0, //用户2操作状态 0-未操作 1-启用 2-保存
      user1SaveSending: false, //“保存用户1”指令是否正在发送
      user1EnableSending: false, //“使用用户1”指令是否正在发送
      user2SaveSending: false, //“保存用户2”指令是否正在发送
      user2EnableSending: false, //“使用用户2”指令是否正在发送

      //光照理疗模式选择
      lightTreatModeSetDialogVisible: false, //是否显示光照理疗模式选择对话框
      listDialogType: 1, //0-左侧、1-中间、2-右侧
      lightTreatModelistDialogListData: {
        type: 2, //悬浮位置类型：0-左侧、1-中间、2-右侧
        title: this.$i18n.t("lightTreatModeListDialog.redLight"), //标题
        defaultSet: 0, //默认选中项
        selectedIndex: 0, //第一次选中默认选中项
        list: [
          { name: this.$i18n.t("lightTreatModeListDialog.close") },
          { name: this.$i18n.t("lightTreatModeListDialog.redLight") },
          { name: this.$i18n.t("lightTreatModeListDialog.blueLight") },
          { name: this.$i18n.t("lightTreatModeListDialog.mixLight") },
        ],
      },
      lightTreatModeDialogAttachViewTop: 200,

      //Tip
      closeTip: false, //是否关闭tip

      warmWindTipLeft: 0,
      warmWindTipTop: 0,

      isAiInstall: false, //是否装维App
    };
  },

  created() {
    console.log("-------------MainPage: created -------------");

    // this.showToast("created");
    // getDevCacheAll();
    //获取设备基本信息（初始化设备状态）
    // this.showToast("重载页面");
    // getDeviceInfo();

    /*------------------------设置监听器（必须放在前面）-------------------------*/
    //设备属性事件监听器
    setPropertiesListener(this.propertiesListener);
    //设置标题栏右侧按钮点击事件监听器
    // setgoSettingListener(this.gotoSetting);
    //重写标题栏右侧按钮点击事件
    // overrideTitleBarRightBtn(true);
    //页面状态栏高度监听器
    setStatuBarHeightListener(this.updateStatusBarHeight);
    //设置发送指令的回调函数
    setSendPropertyListener(this.sendPropertyListener);

    //设置获取设备基本信息的监听器（可获取设备名、设备摆放位置、所有属性值，但是有缓存，第二次请求得到的还是第一次的数据）
    setDeviceInfoListener(this.updateDeviceInfo);
    //设置获取设备所有属性信息的监听器
    setDevInfoAllListener(this.updateDevInfoAll);

    //app从后台恢复
    setOnResumeListener(this.updateOnResume);
    //app退到后台
    setOnPauseListener(this.updateOnPause);

    sendUser1EnableListener = this.sendUser1EnableCallback;
    sendUser1SaveListener = this.sendUser1SaveCallback;
    sendUser2EnableListener = this.sendUser2EnableCallback;
    sendUser2SaveListener = this.sendUser2SaveCallback;

    // //创建联动规则的结果监听器
    // setCreateRuleListener(this.updateCreateRule);
    // //获取联动规则的结果监听器
    // setGetRuleListener(this.updateGetRules);
    // //删除联动规则的结果监听器
    // setDeleteRuleListener(this.updateDeleteRules);
    // //激活或休眠联动规则的监听器
    // setControlRuleActiveListener(this.updateControlRuleActive);

    //主动请求属性值，测试，要删除
    // setRequestPropertyListener(this.updataStatusProperties);
    //按服务请求数据的监听器
    //请求switch服务数据的监听器
    // setRequestSwitchPropertiesListener(this.updateSwitchProperties);
    //请求control服务数据的监听器
    // setRequestStatusPropertiesListener(this.updateStatusProperties);
    //请求control服务数据的监听器
    // setRequestControlPropertiesListener(this.updateControlProperties);
    //请求gear服务数据的监听器
    // setRequestGearPropertiesListener(this.updateGearProperties);
    /*----------------------------------------------------------------------*/

    //修改标题栏的样式
    if (getDarkMode() === 2) {
      modifyTitleBar(true);
      this.darkMode = "dark";
    } else {
      modifyTitleBar(false);
      this.darkMode = "light";
    }
    console.log("darkMode = ", this.darkMode);
    console.log("isIOS = ", isIOS());

    //修改标题样式
    // setChangeTitleStyle();
    //获取所有属性值（旧接口）
    getDeviceInfo();
    getDevInfoAll();
    //获取所有属性值（新接口）
    setDevInfoAllListener(this.updateDevInfoAll);
    getDevInfoAll();
    //获取缓存属性值
    setDevCacheAllListener(this.updateDevCacheAll);
    getDevCacheAll();

    //状态栏高度
    getStatusBarHeight();
    //设置标题栏可见性
    setNavigationVisible(false);

    setJumpToSettingListener(this.closeCurrentPage);

    // 开启国际化（根据手机系统语言，选择不同的语言版本）
    this.setLanguage();
    console.log("screenWidth = ", screenWidth);
    console.log("screenHeight = ", screenHeight);
    console.log("flexibleWidth = ", flexibleWidth);
    console.log("flexibleHeight = ", flexibleHeight);
    console.log(screenDescription);
    console.log("dpr = ", screenDpr);

    //是否装维App
    this.isAiInstall = getAiInstall();

    //设置暗黑模式(因为华为装维app的兼容性问题，必须放在最后面调用)
    // 暗黑方案1
    // if (this.getOS() === "iOS") {
    this.changeDarkMode(this.darkMode);
    // }else{
    // // 暗黑方案2
    //   if (this.darkMode === "dark") {
    //     document.querySelector("html").setAttribute("theme", "dark");
    //   }
    // }
  },

  mounted() {
    //屏幕类型
    this.deviceType = screenType;
    //监听屏幕尺寸变化事件（折叠屏折叠时)
    setScreenResizeListener(this.updateScreenResize);

    //故障列表初始化
    this.faultList.faults = {
      //座圈传感器故障
      1: {
        title: this.$i18n.t("fault.ringSensorFault"),
        reason: this.$i18n.t("fault.ringSensorFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //电压检测故障
      2: {
        title: this.$i18n.t("fault.voltTestFault"),
        reason: this.$i18n.t("fault.voltTestFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //魔力泡故障
      3: {
        title: this.$i18n.t("fault.bubbleFault"),
        reason: this.$i18n.t("fault.foamAgentNotEnough"),
        solution: [
          "1." + this.$i18n.t("fault.pleaseReplaceNewAgent"),
          "2." + this.$i18n.t("fault.cantEliminateContactDealerOrCallHotline"),
        ],
      },
      //环温传感器故障
      4: {
        title: this.$i18n.t("fault.tempSensorFault"),
        reason: this.$i18n.t("fault.tempSensorFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //进水传感器故障
      5: {
        title: this.$i18n.t("fault.waterInSensorFault"),
        reason: this.$i18n.t("fault.waterInSensorFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //出水传感器故障
      6: {
        title: this.$i18n.t("fault.waterOutSensorFault"),
        reason: this.$i18n.t("fault.waterOutSensorFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //亮度传感器故障
      7: {
        title: this.$i18n.t("fault.lightSensorFault"),
        reason: this.$i18n.t("fault.lightSensorFault"),
        solution: [
          "1." + this.$i18n.t("fault.resetLightState"),
          "2." + this.$i18n.t("fault.cantEliminateContactDealerOrCallHotline"),
        ],
      },
      //水箱传感器故障
      8: {
        title: this.$i18n.t("fault.boxSensorFault"),
        reason: this.$i18n.t("fault.boxSensorFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //烘干传感器故障
      9: {
        title: this.$i18n.t("fault.dryingSensorFault"),
        reason: this.$i18n.t("fault.dryingSensorFault"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },

      //水温传感器故障
      // {
      //   title: this.$i18n.t("fault.waterTempSensorFault"),
      //   reason: this.$i18n.t("fault.waterTempSensorFault"),
      //   solution: [this.$i18n.t("fault.pleaseContactHotline")],
      // },
    };
    this.faultList.warns = {
      //烘干超温报警
      1: {
        title: this.$i18n.t("fault.dryingTempOut"),
        reason: this.$i18n.t("fault.dryingTempOut"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //座圈超温报警
      2: {
        title: this.$i18n.t("fault.ringTempOut"),
        reason: this.$i18n.t("fault.ringTempOutReason"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //进水超温报警
      3: {
        title: this.$i18n.t("fault.waterInTempOut"),
        reason: this.$i18n.t("fault.waterInTempOutReason"),
        solution: [
          "1." + this.$i18n.t("fault.TurnOffThenTurnOn"),
          "2." + this.$i18n.t("fault.cantEliminateContactDealerOrCallHotline"),
        ],
      },
      //进水超时报警
      4: {
        title: this.$i18n.t("fault.waterInTimeout"),
        reason: this.$i18n.t("fault.waterInTimeout"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //流量异常报警
      5: {
        title: this.$i18n.t("fault.flowFault"),
        reason: this.$i18n.t("fault.flowFaultReason"),
        solution: [
          "1." + this.$i18n.t("fault.openWaterTurnOnPower"),
          "2." + this.$i18n.t("fault.cantEliminateContactDealerOrCallHotline"),
        ],
      },
      //出水超温报警
      6: {
        title: this.$i18n.t("fault.waterOutTempOut"),
        reason: this.$i18n.t("fault.waterOutTempOutReason"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
    };
    this.faultList.reminds = {
      //滤芯已耗尽
      1: {
        title: this.$i18n.t("fault.filterEmptyRemind"),
        reason: this.$i18n.t("fault.filterEmptyRemind"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //发泡剂已用完
      2: {
        title: this.$i18n.t("fault.bubbleEmptyRemind"),
        reason: this.$i18n.t("fault.bubbleEmptyRemind"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
      //发泡剂余量不足
      3: {
        title: this.$i18n.t("fault.bubbleInsufficientRemind"),
        reason: this.$i18n.t("fault.bubbleInsufficientRemind"),
        solution: [this.$i18n.t("fault.pleaseContactHotline")],
      },
    };

    this.lightTreatModelistDialogListData = {
      type: 2, //悬浮位置类型：0-左侧、1-中间、2-右侧
      title: this.$i18n.t("lightTreatModeListDialog.redLight"), //标题
      defaultSet: 0, //默认选中项
      selectedIndex: 0, //第一次选中默认选中项
      list: [
        { name: this.$i18n.t("lightTreatModeListDialog.close") },
        { name: this.$i18n.t("lightTreatModeListDialog.redLight") },
        { name: this.$i18n.t("lightTreatModeListDialog.blueLight") },
        { name: this.$i18n.t("lightTreatModeListDialog.mixLight") },
      ],
    };

    //监听EventBus消息
    eventBus.$on("SettingPage_goback", () => {
      console.log("SettingPage页面返回");
      // this.isFuncSettingsGoBack = true;
    });

    //添加监听器：右滑或点击系统返回键关闭页面
    if (window.history && window.history.pushState) {
      history.pushState(null, null, document.URL);
      window.addEventListener("popstate", this.closeMainPage, false);
    }

    //添加监听器：页面滚动消息
    window.addEventListener("scroll", this.handleScroll, true); // 监听页面滚动

    //弹框位置
    setTimeout(() => {
      this.getLightTreatModeDialogAttchViewTop();
    }, 300);

    //添加监听器：网络状态
    window.addEventListener("online", this.updateOnlineStatus);
    window.addEventListener("offline", this.updateOnlineStatus);

    this.isAiInstall = getAiInstall();
    console.log("isAiInstall = ", this.isAiInstall);
  },

  destroyed() {
    window.removeEventListener("scroll", this.handleScroll, true);
    window.removeEventListener("online", this.updateOnlineStatus);
    window.removeEventListener("offline", this.updateOnlineStatus);
  },

  watch: {},

  computed: {
    //光触媒除臭卡片状态文本
    getDeodorizeSubtitle() {
      if (this.deodorize === 1) {
        //定点模式
        return this.$i18n.t("btnTitle.deodorizeTimeMode");
      } else if (this.deodorize === 2) {
        //定时模式
        return this.$i18n.t("btnTitle.deodorizeTimeRangeMode");
      } else if (this.deodorize === 3) {
        //自动模式
        return this.$i18n.t("btnTitle.deodorizeAutoMode");
      } else {
        //关闭
        return this.$i18n.t("btnTitle.deodorizeCloseMode");
      }
    },
    //获取光照理疗对话框选中条目序号
    getLightTreatModeDialogSelectItem() {
      if (this.redLightMode) {
        return 1;
      } else if (this.blueLightMode) {
        return 2;
      } else if (this.mixLightMode) {
        return 3;
      }
      return 0;
    },
    getFaultViewClickable() {
      if (this.faultList.faultCode !== 0 || this.faultList.warnCode !== 0) {
        return true;
      } else if (this.faultList.remindCode !== 0) {
        return false;
      } else {
        return true;
      }
    },
    getFaultViewStyleType() {
      if (this.faultList.faultCode !== 0 || this.faultList.warnCode !== 0) {
        return 0;
      } else if (this.faultList.remindCode !== 0) {
        return 1;
      } else {
        return 0;
      }
    },
    getStrongModeMoveWashDisable() {
      return !this.waterEffluent;
    },
    getLightTreatModeBtnTitle() {
      if (this.redLightMode) {
        return this.$i18n.t("btnTitle.redLightMode");
      } else if (this.blueLightMode) {
        return this.$i18n.t("btnTitle.blueLightMode");
      } else if (this.mixLightMode) {
        return this.$i18n.t("btnTitle.mixLightMode");
      } else {
        return this.$i18n.t("btnTitle.lightTreatMode");
      }
    },
    getAutoModeBtnTitle() {
      if (this.autoWomanMode) {
        return this.$i18n.t("btnTitle.autoWomanMode");
      } else if (this.autoHipMode) {
        return this.$i18n.t("btnTitle.autoHipMode");
      } else {
        return this.$i18n.t("btnTitle.autoMode");
      }
    },
    getSitWashModeBtnTitle() {
      return this.$i18n.t("btnTitle.sitWash");
    },

    getWashModeContainerStyle() {
      return { height: screenSize(88) + "px", width: "100%", display: "flex" };
    },
    getLightTreatModeDialogItemList() {
      return this.lightTreatModelistDialogListData;
    },
    getSlideDotSize() {
      switch (this.deviceType) {
        case 1:
          return screenSize(Const.phoneSlideDotSize);
        case 2:
          return screenSize(Const.padVSlideDotSize);
        case 3:
          return screenSize(Const.padHSlideDotSize);
        case 4:
          return screenSize(Const.spreadScreenSlideDotSize);
        case 101:
          return screenSize(Const.phoneSlideDotSize);
        case 102:
          return screenSize(Const.padVSlideDotSize);
        default:
          return screenSize(Const.phoneSlideDotSize);
      }
    },
    //是否折叠屏
    getScreenSpreaded() {
      // console.log("=========MainPage页面 是否折叠屏==========");

      if (this.getOS() === "iOS") {
        console.log("iOS屏幕");
        return false;
      } else {
        if (
          (this.screenHeight * 1.0) / this.screenWidth <
            Const.screenSpreadedRatio &&
          isScreenSpreaded()
        ) {
          console.log("android折叠屏");
          return true;
        }
        console.log("android非折叠屏");
        return false;
      }

      //下面两行测试用，要删除
      // console.log("强制认为是：折叠屏");
      // return true;
    },
    getMySliderCss() {
      if (
        this.deviceType === 1 ||
        this.deviceType === 3 ||
        this.deviceType === 101
      ) {
        return this.language.indexOf("en") != -1 ? "mySliderEn" : "mySlider";
      } else {
        return this.language.indexOf("en") != -1 ? "mySliderEn" : "mySliderPad";
      }
    },
    //是否翻盖不可点击
    isCoverUnable() {
      return (
        this.seatStatus ||
        this.coverPlateStatus ||
        this.seatRingStatus ||
        this.sprayWash ||
        this.flush ||
        this.smallFlush ||
        this.magicBubble
      );
    },
    //是否翻圈不可点击
    isRingUnable() {
      return (
        this.seatStatus ||
        this.coverPlateStatus ||
        this.seatRingStatus ||
        this.sprayWash ||
        this.flush ||
        this.smallFlush ||
        this.magicBubble
      );
    },
    //是否光照理疗
    isLightTreatMode() {
      return this.redLightMode || this.blueLightMode || this.mixLightMode;
    },
    //是否小冲不可点击
    isSmallFlushUnable() {
      return (
        this.flush ||
        this.smallFlush ||
        this.isWashModeFlushUnable ||
        // this.magicBubble ||
        this.sprayWash ||
        this.coverPlateStatus ||
        this.seatRingStatus ||
        this.warmWindMode ||
        this.isLightTreatMode ||
        !this.waterLevel
      );
    },
    //是否大冲不可点击
    isBigFlushUnable() {
      return (
        this.flush ||
        this.smallFlush ||
        this.isWashModeFlushUnable ||
        // this.magicBubble ||
        this.sprayWash ||
        this.coverPlateStatus ||
        this.seatRingStatus ||
        this.warmWindMode ||
        this.isLightTreatMode ||
        !this.waterLevel
      );
    },
    //第二排按钮是否全部不可点击
    isModeBtnsUnable() {
      return this.getModeUnable && this.getWindDisable;
    },
    //第一排按钮是否全部不可点击
    isFirstLineBtnsUnable() {
      return (
        this.isCoverUnable &&
        this.isRingUnable &&
        this.isBigFlushUnable &&
        this.isSmallFlushUnable
      );
    },
    //喷嘴设置不可用
    isSpraySliderUnable() {
      return (
        !this.online ||
        this.warmWindMode ||
        this.wideWash ||
        !this.isWashMode ||
        !this.waterEffluent
      );
      //测试用，要删除
      // return !this.online || this.warmWindMode || this.wideWash || !this.isWashMode;
    },
    //水压设置不可用
    isWaterPressUnable() {
      return (
        !this.online ||
        this.warmWindMode ||
        !this.isWashMode ||
        !this.waterEffluent
      );
      //测试用，要删除
      // return !this.online || this.warmWindMode || !this.isWashMode;
    },
    //幅度设置不可用
    isRangeUnable() {
      return (
        !this.online || this.warmWindMode || !this.isWashMode || !this.wideWash
      );
    },
    //是否拥有浴霸设备
    hasBathHeaterDevice() {
      // return true; //测试代码，需要删除
      return this.bathHeaterId != null;
    },
    //是否拥有毛巾架设备
    hasTowelDevice() {
      return true; //测试代码，需要删除
      // return this.towelId != null;
    },

    //喷嘴自洁是否可点击
    isSprayWashClickable() {
      return this.online && !this.seatStatus;
    },

    //是否流量异常
    isFlowFault() {
      return this.faultList.warnCode === 5;
    },

    //是否进水超温告警
    isWaterIntoOverTempWarn() {
      return this.faultList.warnCode === 3;
    },
    //是否出水超温告警
    isWaterOutOverTempWarn() {
      return this.faultList.warnCode === 6;
    },

    //是否故障
    isBreakDown() {
      return this.faultList.warnCode !== -1 || this.faultList.faultCode !== -1;
    },

    //是否使“一键关闭”按钮生效（要求自动模式、臀洗模式、妇洗模式、暖风模式之一开启）
    isPowerOn() {
      return (
        this.autoHipMode ||
        this.autoWomanMode ||
        this.hipMode ||
        this.womanMode ||
        this.warmWindMode ||
        this.strongMode ||
        this.sprayWash
      );
    },

    //冲洗模式中，不能冲洗
    isWashModeFlushUnable() {
      return (
        this.strongMode ||
        this.hipMode ||
        this.womanMode ||
        this.autoHipMode ||
        this.autoWomanMode ||
        this.sitWashMode
      );
    },

    //是否清洗模式（助便强洗、自动模式、臀洗模式、妇洗模式、坐浴模式）
    isWashMode() {
      return (
        this.strongMode ||
        this.autoHipMode ||
        this.autoWomanMode ||
        this.hipMode ||
        this.womanMode ||
        this.sitWashMode
      );
    },
    //理疗不可用(冲刷、暖风)
    getLightTreatUnable() {
      return !this.seatStatus || this.flush || this.smallFlush;
    },
    //什么情况下清洗模式不可点击
    getModeUnable: function () {
      if (!this.online) return false;
      return (
        !this.seatStatus ||
        this.flush ||
        this.smallFlush ||
        this.magicBubble ||
        this.isFlowFault ||
        this.isWaterIntoOverTempWarn ||
        this.isWaterOutOverTempWarn
      );
    },
    //是否暖风按钮不可用
    getWindDisable: function () {
      return !(
        this.online &&
        this.seatStatus &&
        !this.magicBubble &&
        !this.sprayWash &&
        !this.flush &&
        !this.smallFlush
      );
    },
    //是否暖风按钮可用
    getWindEnable: function () {
      return (
        this.online &&
        this.seatStatus &&
        !this.magicBubble &&
        !this.sprayWash &&
        !this.flush &&
        !this.smallFlush
      );
    },
    //是否光触媒除臭按钮可用
    getDeodorizeEnable() {
      return true;
    },
    //是否喷嘴自洁按钮可用
    getSprayCleanEnable() {
      return (
        this.online &&
        !this.coverPlateStatus &&
        !this.seatRingStatus &&
        !this.seatStatus &&
        !this.magicBubble &&
        !this.sprayWashIsLocking &&
        !this.smallFlush &&
        !this.flush
      );
    },
    //是否喷嘴拆卸按钮可用 (离座、开盖、开圈、盖圈没有动作、未开启喷嘴自洁、未开启大小冲)
    getSprayDisassembleEnable() {
      return (
        this.online &&
        !this.seatStatus &&
        // !this.magicBubble &&
        !this.sprayWash &&
        !this.sprayWashIsLocking &&
        !this.smallFlush &&
        !this.flush &&
        this.cover &&
        this.ring &&
        !this.coverPlateStatus &&
        !this.seatRingStatus
      );
    },
    //是否疏通模式按钮可用(离座、开盖、盖圈未动作)
    getDredgeModeEnable() {
      return (
        this.online &&
        !this.seatStatus &&
        this.cover &&
        !this.coverPlateStatus &&
        !this.seatRingStatus
      );
    },
    //是否魔力泡按钮可用
    getMagicBubbleEnable() {
      return (
        this.online &&
        !this.sprayWash &&
        !this.isWashMode &&
        !this.warmWindMode &&
        !this.flush &&
        !this.smallFlush &&
        !this.isFlowFault &&
        !this.bubbleIsLocking &&
        !this.coverPlateStatus &&
        !this.seatRingStatus
      );
    },
    //是否加液盒按钮可用
    getFillingBoxEnable() {
      //1.座圈未开启时，不可用
      return this.ring && !this.seatRingStatus;
    },

    getUser1Enable() {
      return true;
    },
    getUser2Enable() {
      return true;
    },

    getmoreModeTitle: function () {
      return this.showMoreList
        ? this.$i18n.t("btnTitle.fold")
        : this.$i18n.t("btnTitle.unfold");
    },

    getFoamState: function () {
      switch (this.foamLeftState) {
        case 0:
          return this.$i18n.t("foam.state0");
        case 1:
          return this.$i18n.t("foam.state1");
        case 2:
          return this.$i18n.t("foam.state2");
        case 3:
          return this.$i18n.t("foam.state3");
      }
    },

    getStateTitle: function () {
      if (this.online) {
        if (this.strongMode) {
          if (this.moveWash) {
            return this.$i18n.t("status.strongMoveWashing");
          } else {
            return this.$i18n.t("status.strongWashing");
          }
        } else if (this.autoHipMode) {
          return this.$i18n.t("status.autoHipWashing");
        } else if (this.autoWomanMode) {
          return this.$i18n.t("status.autoWomanWashing");
        } else if (this.hipMode) {
          if (this.wideWash) {
            return this.$i18n.t("status.wideWashing");
          } else {
            return this.$i18n.t("status.hipWashing");
          }
        } else if (this.womanMode) {
          if (this.moveWash) {
            return this.$i18n.t("status.womanMoveWashing");
          } else {
            return this.$i18n.t("status.womanWashing");
          }
        } else if (this.sitWashMode) {
          if (this.moveWash) {
            return this.$i18n.t("status.sitMoveWashing");
          } else {
            return this.$i18n.t("status.sitWashing");
          }
        } else if (this.warmWindMode) {
          if (this.smallFlush || this.flush) {
            return this.$i18n.t("status.working");
          } else {
            return this.$i18n.t("status.warmWinding");
          }
        } else if (
          this.redLightMode ||
          this.blueLightMode ||
          this.mixLightMode
        ) {
          return this.$i18n.t("status.lightTreating");
        } else if (this.smallFlush || this.flush) {
          if (this.smallFlush) {
            return this.$i18n.t("status.smallFlushing");
          } else {
            return this.$i18n.t("status.bigFlushing");
          }
          // return this.$i18n.t("status.flushing");
        } else if (this.magicBubble) {
          return this.$i18n.t("status.bubbling");
        } else if (this.sprayWash) {
          return this.$i18n.t("status.sprayWashing");
        } else if (this.coverOpening) {
          if (this.ringOpening) {
            return this.$i18n.t("status.coverRingOpening");
          } else {
            return this.$i18n.t("status.coverOpening");
          }
        } else if (this.coverClosing) {
          if (this.ringClosing) {
            return this.$i18n.t("status.coverRingClosing");
          } else {
            return this.$i18n.t("status.coverClosing");
          }
        } else if (this.ringOpening) {
          return this.$i18n.t("status.ringOpening");
        } else if (this.ringClosing) {
          return this.$i18n.t("status.ringClosing");
        }
        // else if (this.seatRingStatus && !this.coverPlateStatus) {
        //   return this.$i18n.t("status.doring");
        // } else if (this.coverPlateStatus && this.seatRingStatus) {
        //   return this.$i18n.t("status.ringandcovering");
        // }
        else if (this.seatStatus) {
          return this.$i18n.t("status.hasSeated");
        } else {
          return this.$i18n.t("status.waiting");
        }
      } else {
        return this.$i18n.t("status.outline");
      }
    },

    getPowerImg: function () {
      return this.isPowerOn
        ? require("../assets/img/light/ic_power_on.png")
        : require("../assets/img/light/ic_power_off.png");
    },
    getCoverImg() {
      if (this.cover) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_cover_plate_on.png");
        } else {
          return require("../assets/img/dark/ic_cover_plate_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_cover_plate_off.png");
        } else {
          return require("../assets/img/dark/ic_cover_plate_off_dark.png");
        }
      }
    },
    getRingImg: function () {
      if (this.ring) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_seat_ring_on.png");
        } else {
          return require("../assets/img/dark/ic_seat_ring_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_seat_ring_off.png");
        } else {
          return require("../assets/img/dark/ic_seat_ring_off_dark.png");
        }
      }
    },
    getFlushImg: function () {
      if (this.flush) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_flushing_on.png");
        } else {
          return require("../assets/img/dark/ic_flushing_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_flushing_off.png");
        } else {
          return require("../assets/img/dark/ic_flushing_off_dark.png");
        }
      }
    },
    getSmallFlushImg: function () {
      if (this.smallFlush) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_small_flushing_on.png");
        } else {
          return require("../assets/img/dark/ic_small_flushing_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_small_flushing_off.png");
        } else {
          return require("../assets/img/dark/ic_small_flushing_off_dark.png");
        }
      }
    },
    getLightTreatModeImg: function () {
      if (this.redLightMode || this.blueLightMode || this.mixLightMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_light_treat_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_light_treat_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_light_treat_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_light_treat_mode_off_dark.png");
        }
      }
    },
    getAutoModeImg: function () {
      if (this.autoHipMode || this.autoWomanMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_auto_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_auto_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_auto_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_auto_mode_off_dark.png");
        }
      }
    },
    getAutoHipModeImg: function () {
      if (this.autoHipMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_auto_hip_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_auto_hip_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_auto_hip_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_auto_hip_mode_off_dark.png");
        }
      }
    },
    getAutoWomanModeImg: function () {
      if (this.autoWomanMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_auto_woman_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_auto_woman_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_auto_woman_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_auto_woman_mode_off_dark.png");
        }
      }
    },
    getHipModeImg: function () {
      if (this.hipMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_hip_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_hip_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_hip_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_hip_mode_off_dark.png");
        }
      }
    },
    getWomanModeImg: function () {
      if (this.womanMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_woman_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_woman_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_woman_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_woman_mode_off_dark.png");
        }
      }
    },
    getWarmWindImg: function () {
      if (this.darkMode === "light") {
        return this.warmWindMode
          ? require("../assets/img/light/ic_warm_wind_on.png")
          : require("../assets/img/light/ic_warm_wind_off.png");
      } else {
        return this.warmWindMode
          ? require("../assets/img/dark/ic_warm_wind_on_dark.png")
          : require("../assets/img/dark/ic_warm_wind_off_dark.png");
      }
    },
    getStrongModeImg() {
      if (this.strongMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_strong_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_strong_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_strong_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_strong_mode_off_dark.png");
        }
      }
    },
    getWarmWindModeImg() {
      if (this.warmWindMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_warm_wind_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_warm_wind_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_warm_wind_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_warm_wind_mode_off_dark.png");
        }
      }
    },
    getSitWashModeImg() {
      if (this.sitWashMode) {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_sit_wash_mode_on.png");
        } else {
          return require("../assets/img/dark/ic_sit_wash_mode_on_dark.png");
        }
      } else {
        if (this.darkMode === "light") {
          return require("../assets/img/light/ic_sit_wash_mode_off.png");
        } else {
          return require("../assets/img/dark/ic_sit_wash_mode_off_dark.png");
        }
      }
    },
    getWideWashImg: function () {
      if (this.darkMode === "light") {
        return this.wideWash
          ? require("../assets/img/light/ic_wide_wash_on.png")
          : require("../assets/img/light/ic_wide_wash_off.png");
      } else {
        return this.wideWash
          ? require("../assets/img/dark/ic_wide_wash_on_dark.png")
          : require("../assets/img/dark/ic_wide_wash_off_dark.png");
      }
    },
    getMoveWashImg: function () {
      if (this.darkMode === "light") {
        return this.moveWash
          ? require("../assets/img/light/ic_move_wash_on.png")
          : require("../assets/img/light/ic_move_wash_off.png");
      } else {
        return this.moveWash
          ? require("../assets/img/dark/ic_move_wash_on_dark.png")
          : require("../assets/img/dark/ic_move_wash_off_dark.png");
      }
    },
    getMagicalBubbleImg: function () {
      if (this.darkMode === "light") {
        return this.magicBubble
          ? require("../assets/img/light/ic_magical_bubble_on.png")
          : require("../assets/img/light/ic_magical_bubble_off.png");
      } else {
        return this.magicBubble
          ? require("../assets/img/dark/ic_magical_bubble_on_dark.png")
          : require("../assets/img/dark/ic_magical_bubble_off_dark.png");
      }
    },
    getUser1Img: function () {
      if (this.darkMode === "light") {
        return require("../assets/img/light/ic_user1_on.png");
      } else {
        return require("../assets/img/light/ic_user1_on.png");
      }
    },
    getUser2Img: function () {
      if (this.darkMode === "light") {
        return require("../assets/img/light/ic_user2_on.png");
      } else {
        return require("../assets/img/light/ic_user2_on.png");
      }
    },
    getSprayWashImg: function () {
      if (this.darkMode === "light") {
        return this.sprayWash
          ? require("../assets/img/light/ic_spray_wash_on.png")
          : require("../assets/img/light/ic_spray_wash_off.png");
      } else {
        return this.sprayWash
          ? require("../assets/img/dark/ic_spray_wash_on_dark.png")
          : require("../assets/img/dark/ic_spray_wash_off_dark.png");
      }
    },
    getSprayDisassembleImg: function () {
      if (this.darkMode === "light") {
        return this.sprayDisassemble
          ? require("../assets/img/light/ic_spray_disassemble_on.png")
          : require("../assets/img/light/ic_spray_disassemble_off.png");
      } else {
        return this.sprayDisassemble
          ? require("../assets/img/dark/ic_spray_disassemble_on_dark.png")
          : require("../assets/img/dark/ic_spray_disassemble_off_dark.png");
      }
    },
    getDeodorizeImg: function () {
      if (this.darkMode === "light") {
        return this.deodorize !== 0
          ? require("../assets/img/light/ic_deodorize_on.png")
          : require("../assets/img/light/ic_deodorize_off.png");
      } else {
        return this.deodorize !== 0
          ? require("../assets/img/dark/ic_deodorize_on_dark.png")
          : require("../assets/img/dark/ic_deodorize_off_dark.png");
      }
    },
    getDredgeModeImg: function () {
      if (this.darkMode === "light") {
        return this.dredgeMode
          ? require("../assets/img/light/ic_dredge_on.png")
          : require("../assets/img/light/ic_dredge_off.png");
      } else {
        return this.dredgeMode
          ? require("../assets/img/dark/ic_dredge_on_dark.png")
          : require("../assets/img/dark/ic_dredge_off_dark.png");
      }
    },
    getFillingBoxImg: function () {
      if (this.darkMode === "light") {
        return this.fillingBox
          ? require("../assets/img/light/ic_filling_box_on_light.png")
          : require("../assets/img/light/ic_filling_box_off_light.png");
      } else {
        return this.fillingBox
          ? require("../assets/img/light/ic_filling_box_on_light.png")
          : require("../assets/img/dark/ic_filling_box_off_dark.png");
      }
    },
    getFoamRightArrowImg: function () {
      if (this.darkMode === "light") {
        return require("../assets/img/light/ic_right_arrow.png");
      } else {
        return require("../assets/img/dark/ic_right_arrow_dark.png");
      }
    },
    getFuncSettingImg: function () {
      if (this.darkMode === "light") {
        return require("../assets/img/light/ic_function_setting_off.png");
      } else {
        return require("../assets/img/dark/ic_function_setting_off_dark.png");
      }
    },
    getFaultTipImg: function () {
      if (this.darkMode === "light") {
        return require("../assets/img/light/ic_fault_tip.png");
      } else {
        return require("../assets/img/dark/ic_fault_tip_dark.png");
      }
    },
    getFaultTipArrow: function () {
      if (this.darkMode === "light") {
        return require("../assets/img/light/ic_fault_right_arrow.png");
      } else {
        return require("../assets/img/dark/ic_fault_right_arrow_dark.png");
      }
    },
    getMoreArrowImg: function () {
      if (this.darkMode === "light") {
        return this.showMoreList
          ? require("../assets/img/light/ic_more_close.png")
          : require("../assets/img/light/ic_more_open.png");
      } else {
        return this.showMoreList
          ? require("../assets/img/dark/ic_more_close_dark.png")
          : require("../assets/img/dark/ic_more_open_dark.png");
      }
    },

    getRangeSlideData() {
      return {
        title: "幅度",
        marginStart: 8,
        marginStartEn: 3,
        marginEnd: -8,
        marginEndEn: -3,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.rangeValue1"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          25: {
            label: this.$i18n.t("btnTitle.rangeValue2"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          50: {
            label: this.$i18n.t("btnTitle.rangeValue3"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          75: {
            label: this.$i18n.t("btnTitle.rangeValue4"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.rangeValue5"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
        },
      };
    },

    getWaterPressureSlideData() {
      return {
        title: "水压",
        marginStartEn: 3,
        marginStart: 8,
        marginEnd: -8,
        marginEndEn: -3,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.wpWeakest"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          25: {
            label: this.$i18n.t("btnTitle.wpWeak"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          50: {
            label: this.$i18n.t("btnTitle.wpStandard"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          75: {
            label: this.$i18n.t("btnTitle.wpStrong"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.wpStrongest"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
        },
      };
    },
    getWaterTemperatureSlideData() {
      return {
        title: "水温",
        marginStart: 10,
        marginStartEn: 17,
        marginEnd: -10,
        marginEndEn: -10,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.wtRoom"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          20: {
            label: this.$i18n.t("btnTitle.wtLowest"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          40: {
            label: this.$i18n.t("btnTitle.wtLow"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          60: {
            label: this.$i18n.t("btnTitle.wtStandard"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          80: {
            label: this.$i18n.t("btnTitle.wtHigh"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.wtHighest"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
        },
      };
    },

    getSprayPositionSlideData() {
      return {
        title: "喷嘴",
        marginStartEn: 10,
        marginStart: 10,
        marginEnd: -10,
        marginEndEn: -12,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.spBackest"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          25: {
            label: this.$i18n.t("btnTitle.spBack"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          50: {
            label: this.$i18n.t("btnTitle.spStandard"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          75: {
            label: this.$i18n.t("btnTitle.spFront"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.spFrontest"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
        },
      };
    },
    getSeatTemperatureSlideData() {
      return {
        title: "座温",
        marginStart: 10,
        marginStartEn: 16,
        marginEnd: -10,
        marginEndEn: -10,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.stRoom"), //"常温",
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          20: {
            label: this.$i18n.t("btnTitle.stLowest"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          40: {
            label: this.$i18n.t("btnTitle.stLow"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          60: {
            label: this.$i18n.t("btnTitle.stStandard"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          80: {
            label: this.$i18n.t("btnTitle.stHigh"),
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.stHighest"),
            labelStyle: {
              color: null,
              margin: null,
            },
          },
        },
      };
    },

    getWindTemperatureSlideData() {
      return {
        title: "水温",
        marginStart: 10,
        marginStartEn: 16,
        marginEnd: -5,
        marginEndEn: -10,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.wdtRoom"), //"常温",
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          33: {
            label: this.$i18n.t("btnTitle.wdtLow"), // 低温
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          67: {
            label: this.$i18n.t("btnTitle.wdtStandard"), // 标准,
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.wdtHigh"), //高,
            labelStyle: {
              color: null,
              margin: null,
            },
          },
        },
      };
    },

    //风速滑条样式数据
    getWindSpeedSlideData() {
      return {
        title: this.$i18n.t("btnTitle.windSpeed"),
        marginStart: 5,
        marginStartEn: 10,
        marginEnd: -5,
        marginEndEn: -10,
        marks: {
          0: {
            label: this.$i18n.t("btnTitle.wdSpeedLow"), //低,
            labelStyle: {
              color: null,
              margin: null,
            },
          },
          50: {
            label: this.$i18n.t("btnTitle.wdSpeedStandard"), //标准,
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
          100: {
            label: this.$i18n.t("btnTitle.wdSpeedHigh"), //高
            labelStyle: {
              color: null,
              margin: null,
            },
            style: {
              backgroundColor: null,
            },
          },
        },
      };
    },
  },

  filters: {},

  methods: {
    copyPhone() {
      console.log("点击复制按钮");
      let url = "4001919999";
      //新建一个文本框
      let oInput = document.createElement("input");
      //赋值给文本框
      oInput.value = url;
      document.body.appendChild(oInput);
      // 选择对象;
      oInput.select();
      // 执行浏览器复制命令
      document.execCommand("Copy");
      //复制完成删除掉输入框
      oInput.remove();
      console.log("复制成功");
      this.showToast(this.$i18n.t("toast.copySuccess"));
    },
    //网络状态回调
    updateOnlineStatus(e) {
      const { type } = e;
      this.netWorkOnLine = type === "online";
      console.log("监听到网络状态：", this.netWorkOnLine);
      if (this.netWorkOnLine) {
        //设备属性事件监听器
        setPropertiesListener(this.propertiesListener);

        //设置获取设备信息的监听器(有缓存)
        setDeviceInfoListener(this.updateDeviceInfo);
        //获取设备基本信息（有缓存）
        getDeviceInfo();

        //设置获取设备全部数据的结果回调（无缓存）
        setDevInfoAllListener(this.updateDevInfoAll);
        getDevInfoAll();

        //加载缓存信息（离线时调用）
        setDevCacheAllListener(this.updateDevCacheAll);
        getDevCacheAll();
      }
    },
    getWarmWindTipPosition() {
      this.warmWindTipLeft = 0; //this.$refs.warmWindTipRef.getBoundingClientRect().left;
      this.warmWindTipTop = 0; // this.$refs.warmWindTipRef.getBoundingClientRect().top;
    },
    updateScreenResize(newScreenType) {
      setTimeout(() => {
        this.getWarmWindTipPosition();
      }, 500);
      this.getLightTreatModeDialogAttchViewTop();
      this.deviceType = newScreenType;
      // console.log("屏幕resize: this.deviceType = ", newScreenType);
      // console.log("屏幕resize: this.flexibleHeight = ", flexibleHeight);
      // console.log("屏幕resize: this.flexibleWidth = ", flexibleWidth);
      // console.log("屏幕resize: this.screenHeight = ", screenHeight);
      // console.log("屏幕resize: this.screenWidth = ", screenWidth);
      // console.log("屏幕resize: this.isScreenSpreaded = ", isScreenSpreaded());
    },
    handleScroll() {
      this.getLightTreatModeDialogAttchViewTop();
      this.getWarmWindTipPosition();
      // this.closeTip = true;
    },
    getLightTreatModeDialogAttchViewTop() {
      this.lightTreatModeDialogAttachViewTop =
        this.$refs.lightTreatModeBtnId.getBoundingClientRect().top;
    },
    getLightTreatModeDialogAttachViewWidth() {
      switch (this.listDialogType) {
        case 0:
        case 1:
        case 2:
          this.$nextTick(() => {
            return this.$refs.lightTreatModeBtnId.clientWidth;
          });
      }
    },

    //选择光照模式选项后
    hasSelectedLightTreatMode(selectedIndex) {
      if (selectedIndex === 1) {
        console.log("点击红光模式");
        this.beforeChangeStatusSendProperty();
        this.setMode(8, true);
        let val = this.redLightMode ? 1 : 0;
        this.prepareSendProperty({ control: { phototherapy: val } });
      } else if (selectedIndex === 2) {
        console.log("点击蓝光模式");
        this.beforeChangeStatusSendProperty();
        this.setMode(9, true);
        let val = this.blueLightMode ? 2 : 0;
        this.prepareSendProperty({ control: { phototherapy: val } });
      } else if (selectedIndex === 3) {
        console.log("点击混合模式");
        this.beforeChangeStatusSendProperty();
        this.setMode(10, true);
        let val = this.blueLightMode ? 3 : 0;
        this.prepareSendProperty({ control: { phototherapy: val } });
      } else if (selectedIndex === 0) {
        if (this.redLightMode || this.blueLightMode || this.mixLightMode) {
          console.log("点击关闭光照理疗模式");
          this.beforeChangeStatusSendProperty();
          this.closeMode();
          let val = 0;
          this.prepareSendProperty({ control: { phototherapy: val } });
        }
      }
    },
    cancelLightTreatModeSelect() {
      console.log("取消选择");
    },
    closeCurrentPage(res) {},
    addSeatTempStepStyle() {
      // return "custom-step";
      return this.seatTemperatureValue == 0 || this.seatTemperatureValue == 100
        ? "custom-step-hidden"
        : "custom-step";
    },
    //获取当前手机的操作系统类型
    getOS() {
      var u = navigator.userAgent;
      if (u.indexOf("Mac OS X") > -1) {
        return "iOS";
      } else {
        return "Android";
      }
      // } else if (u.indexOf("Android") > -1 || u.indexOf("Linux") > -1) {
      //   return "Android";
      // }
    },

    //当前语言是否中文
    isChinese() {
      return (
        getAppLanguage().indexOf("zh") != -1 ||
        getAppLanguage().indexOf("bo") != -1 ||
        getAppLanguage().indexOf("ug") != -1
      );
    },

    //设置当前语言
    setLanguage() {
      if (
        // navigator.language.indexOf("zh") != -1 ||
        // navigator.language.indexOf("bo") != -1 ||
        // navigator.language.indexOf("ug") != -1
        this.isChinese()
      ) {
        this.$i18n.locale = "zh";
        this.language = "zh";
      } else {
        this.$i18n.locale = "en";
        this.language = "en";
      }
    },
    //改变语言
    changeLanguage(language) {
      localStorage.setItem("lang", language);
      // window.location.reload();
    },
    //显示折叠区域
    setShowCollapse: function () {
      if (
        this.autoHipMode ||
        this.autoWomanMode ||
        this.hipMode ||
        this.womanMode ||
        this.strongMode ||
        this.warmWindMode
      ) {
        this.showMoreList = true;
      }
    },
    //隐藏折叠区域
    setHideCollapse: function () {
      if (this.warmWindMode) {
        this.showMoreList = false;
      }
    },

    //按服务顺序加载属性数据
    loadAllDataByService() {
      this.isLoadAllDataByService = true;
      getStatusProperties();
    },
    //获取“switch“服务下所有属性值的结果回调
    updateSwitchProperties: function (data) {
      this.stopData = data;
    },
    //获取"status"服务下所有属性值的结果回调
    updateStatusProperties: function (data) {
      if (data.errcode) {
        this.showToast("重载数据失败，请检查网络");
        this.isLoadAllDataByService = false;
      } else {
        //iOS手机收到的数据不是按服务的，收到的是所有服务的数据（是智慧生活的bug）
        if (this.getOS() === "iOS") {
          console.log("iOS获取到数据：");
          console.log(data);
          if (data.services != null) {
            for (var i = 0; i < data.services.length; i++) {
              this.propertiesListener(data.services[i]);
            }
          }
        } else {
          console.log("Android获取到数据：status");
          console.log(data);
          this.updateUIByStatusService(data);
          //请求control服务的所有属性数据
          // if (this.isLoadAllDataByService) {
          getControlProperties();
          //   }
        }
      }
    },
    //获取"switch"服务下所有属性值的结果回调
    updateControlProperties: function (data) {
      if (data.errcode) {
        this.showToast("重载数据失败，请检查网络");
        this.isLoadAllDataByService = false;
      } else {
        // this.testControlData = data; //测试用，要删除
        console.log("Android获取到数据：control");
        console.log(data);
        this.updateUIByControlService(data);
        //请求gear服务的所有属性数据
        // if (this.isLoadAllDataByService) {
        getGearProperties();
        // }
      }
    },
    //获取"gear"服务下所有属性值的结果回调
    updateGearProperties: function (data) {
      if (data.errcode) {
        this.showToast("重载数据失败，请检查网络");
        this.isLoadAllDataByService = false;
      } else {
        console.log("Android获取到数据：gear");
        console.log(data);
        this.updateUIByGearService(data);
        // if (this.isLoadAllDataByService) {
        this.getSettingServiceProperties();
        // }
      }
    },

    //获取“setting”服务下所有属性值的结果回调
    updateSettingProperties: function (data) {
      // toast(1000, data);
      if (data.errcode) {
        this.showToast("重载数据失败，请检查网络");
      } else {
        console.log("Android获取到数据：setting");
        console.log(data);
        this.testSettingData = data;
        this.settingData = data;
        // this.updateUIBySettingService(data);
      }
      this.isLoadAllDataByService = false;
    },

    //请求指定服务的设备数据
    getSettingServiceProperties() {
      let sid = "setting"; //服务的id
      let pid = ""; //属性的id,空的话，请求的就是服务下的所有属性数据
      getProperty(sid, pid);
    },
    updateServiceData: function (data) {},
    sceneBathHeaterSwitchValueChange: function (newValue) {
      if (this.sceneBathHeaterLock) return;
      if (newValue) this.sceneBathHeaterLock = true;
      let ruleObj = {
        name: "ToiletBathheaterRule01",
        conditions: [
          {
            type: "DEVICE_DATA",
            deviceInfo: {
              devId: this.deviceId,
              devType: "066",
              path: "status/seatStatus",
            },
            operator: "=",
            value: "1",
          },
        ],
        actions: [
          {
            type: "DEVICE_CMD",
            devId: "224f008e-b995-4d16-a558-9660bfcf06d5",
            devType: "0BA",
            cmd: {
              sid: "wind",
              messageType: "POST",
              messageBody: {
                on: 1,
              },
            },
          },
        ],
      };
      createRule(ruleObj);
    },
    sceneTowelSwitchValueChange: function (newValue) {
      let sendVal = newValue ? 1 : 0;
    },
    //创建联动规则的结果回调
    updateCreateRule: function (data) {
      if (data.errcode === 0) {
        this.sceneBathHeaterLock = true;
      } else {
        this.sceneBathHeaterLock = false;
      }
      this.showToast(data.errcode === 0 ? "场景创建成功" : "场景创建失败");
    },
    //获取联动规则
    getAllRules: function () {
      let rulesFilter = {};
      // let rulesFilter = {};
      getRules(rulesFilter);
    },
    //获取联动规则的结果回调
    updateGetRules: function (data) {
      if (data != null && data.length > 0) {
        this.rules = data;
        // for (var i = 0; i < data.length; i++) {
        //   if (i === 1) {
        //     let rule = data[i];
        //     if (rule.name != null) toast(2000, rule.name);
        //     let actions = rule.actions;
        //     if (actions != null && actions.length > 0) {
        //       for (var j = 0; j < actions.length; j++) {
        //         let action = actions[j];
        //         // this.showToast(i + "." + action.cmd.sid);
        //         // this.showToast(action.devId);
        //         // this.showToast(action.sid);
        //       }
        //     }
        //   }
        // }
      }
    },
    //删除联动规则
    deleteRules: function () {
      if (this.rules != null && this.rules.length > 0) {
        var ruleIdArray = new Array();
        for (var i = 0; i < this.rules.length; i++) {
          ruleIdArray[i] = this.rules[i].ruleId;
        }
        // this.showToast("deleteRules");
        deleteRule(ruleIdArray[i]);
      } else {
        this.showToast("rules is null");
      }
    },
    //删除联动规则的结果回调
    updateDeleteRules: function (res) {
      if (res.errcode === 0) {
        this.showToast("规则删除成功");
      } else {
        this.showToast("规则删除失败");
      }
    },
    //激活或休眠联动规则的结果回调
    updateControlRuleActive: function (res) {
      if (res.errcode === 0) {
        this.showToast("规则激活成功");
      } else {
        this.showToast("规则激活失败");
      }
    },
    //与毛巾架联动
    bindTowelProperty: function () {
      // let ruleObj = {
      //   name: "Rule01",
      //   conditions: [
      //     {
      //       type: "DEVICE_DATA",
      //       deviceInfo: {
      //         devId: "545dc550-2658-4300-b5cc-2b42faf8a18d",
      //         devType: "066",
      //         path: "status/seatStatus",
      //       },
      //       operator: "=",
      //       value: "1",
      //     },
      //   ],
      //   actions: [
      //     {
      //       type: "DEVICE_CMD",
      //       devId: "224f008e-b995-4d16-a558-9660bfcf06d5",
      //       devType: "0BA",
      //       cmd: {
      //         sid: "wind",
      //         messageType: "POST",
      //         messageBody: {
      //           on: 1,
      //         },
      //       },
      //     },
      //   ],
      // };
      // createRule(ruleObj);
    },

    //app从后台恢复
    updateOnResume: function () {
      console.log("App从后台恢复到前台");
      // this.isOnResumeUpdating = true;

      //设备属性事件监听器
      setPropertiesListener(this.propertiesListener);

      // //设置获取设备信息的监听器(有缓存)
      setDeviceInfoListener(this.updateDeviceInfo);
      // //获取设备基本信息（有缓存）
      getDeviceInfo();

      //设置获取设备全部数据的结果回调（无缓存）
      setDevInfoAllListener(this.updateDevInfoAll);
      getDevInfoAll();

      //加载缓存信息（离线时调用）
      setDevCacheAllListener(this.updateDevCacheAll);
      getDevCacheAll();
    },
    //app退到后台的回调
    updateOnPause: function () {
      console.log("App退到后台");
    },
    //获取设备基本信息(缓存）的回调方法用于刷新UI
    updateDeviceInfo: function (data) {
      console.log("旧接口getDeviceInfo：");
      console.log(data);
      if (data.errcode) {
        console.log("getDeviceInfo 旧接口返回错误: errcode = ", data.errcode);
      } else {
        this.deviceName = data.devName; //设备名称
        // this.deviceId = data.deviceId; //设备Id
        // this.online = data.status === "online"; //是否在线
        // if (data.roomName != null && data.roomName !== "null") {
        //   this.roomName = data.roomName; //设备摆放位置
        // }
        //设备所有控制属性值
        if (data.services != null) {
          for (var i = 0; i < data.services.length; i++) {
            this.propertiesListener(data.services[i]);
          }
        }
      }
    },
    //获取设备所有控制属性值的回调方法用于刷新UI
    updateDevInfoAll: function (data) {
      // toast(1000, "updateDevInfoAll");
      console.log("新接口getDevInfoAll：");
      console.log(data);
      if (data.errcode) {
        console.log("getDevInfoAll 新接口返回错误: errcode = ", data.errcode);
      } else {
        //第一次进页面 或 onResume返回时 不更新设备名称
        if (this.firstIntoPage) {
          console.log("第一次进页面: 新接口设备名为：", data.devName);
          this.firstIntoPage = false;
          this.deviceNameNewItfc = data.devName; //缓存新接口的设备名
        } else {
          console.log("非第一次进页面: 新接口设备名为：", data.devName);
          console.log(
            "非第一次进页面：新接口设备名为：",
            this.deviceNameNewItfc
          );
          if (this.deviceNameNewItfc !== data.devName) {
            console.log("改名了：", data.devName);
            this.deviceName = data.devName; //设备名称
            this.deviceNameNewItfc = data.devName;
          }
        }

        // this.isOnResumeUpdating = false;
        // this.isFuncSettingsGoBack = false;

        if (data.services != null) {
          // this.testSettingData = data;
          for (var i = 0; i < data.services.length; i++) {
            this.propertiesListener(data.services[i]);
          }
        }
      }
    },
    //缓存数据回调方法
    updateDevCacheAll: function (data) {
      console.log(getCurrentTime(), " getDevCacheAll 缓存接口返回结果：");
      console.log(data);
      if (data.errcode) {
        console.log(
          "getDevCacheAll 缓存接口返回错误: errcode = ",
          data.errcode
        );
      } else {
        this.deviceName = data.devName;
        //更新所有属性值
        if (data.services != null) {
          for (var i = 0; i < data.services.length; i++) {
            this.propertiesListener(data.services[i]);
          }
        }
      }
    },

    //发送指令后的回调
    sendPropertyListener: function (data) {
      if (data.errcode === 0) {
        console.log(getCurrentTime(), "指令发送成功");
        // this.showToast("指令发送成功");
      } else {
        console.log(getCurrentTime(), "指令发送失败");
        // this.showToast("指令发送失败");
        // this.updateUIFromData();
      }
    },
    justifyImgWidth: function (e) {
      // ratio = orgin width / origin height = 968 / 352 = 2.75
      this.materialHeight = e.currentTarget.clientWidth * (94.0 / 164.0);
    },

    gotoFoamPage: function () {
      this.$router.push({
        path: "/foam",
        query: {
          //传递参数，传递的参数会自动转换成string格式，接收时要注意这点
          darkMode: this.darkMode,
          foamstate: this.foamLeftState,
        },
      });
    },
    gotoFilterPage: function () {
      this.$router.push({
        path: "/filter",
        query: {
          //传递参数，传递的参数会自动转换成string格式，接收时要注意这点
          darkMode: this.darkMode,
          filterLeftTime: this.filterLeftTime,
          filterLeftPer: this.filterLeftPer,
        },
      });
    },

    //退出设备页面
    closeDevicePage: function () {
      finishDeviceActivity();
    },
    //更新页面状态栏高度
    updateStatusBarHeight: function (height) {
      this.statusBarHeight = height;
      // this.showToast("height = " + height);
    },
    //点击模式关闭按钮（模式：自动模式、臀洗模式、妇洗模式、烘干模式）
    clickPower(value) {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      if (this.isPowerOn) {
        if (this.sprayWash) {
          this.startSprayWashTimer();
        }
        this.setMode(0, false);
        let val = 0;
        this.prepareSendProperty({ stop: { action: val } });
      }
    },
    //点击盖板按钮
    clickCover: function () {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      if (this.cover) {
        if (this.ring) {
          this.coverPlateStatus = true;
          this.seatRingStatus = true;

          this.coverClosing = true;
          this.ringClosing = true;
          this.coverOpening = false;
          this.ringOpening = false;
        } else {
          this.coverPlateStatus = true;
          this.seatRingStatus = false;

          this.coverClosing = true;
          this.ringClosing = false;
          this.coverOpening = false;
          this.ringOpening = false;
        }
      } else {
        this.coverPlateStatus = true;
        this.seatRingStatus = false;

        this.coverClosing = false;
        this.ringClosing = false;
        this.coverOpening = true;
        this.ringOpening = false;
      }
      this.cover = !this.cover;
      //如果是关闭盖板，那么本地要把座圈先关掉
      if (!this.cover) {
        this.ring = false;
      }
      let val = this.cover ? 1 : 0;
      this.prepareSendProperty({ filpSwitch: { on: val } });
    },
    clickCoverDisable() {
      if (this.isFasterClick()) return;
      //着座中，不能开关盖
      if (this.seatStatus) {
        this.showToast(this.$i18n.t("toast.pleaseStandUp"));
        return;
      }
      //冲水中，不能开关盖
      if (this.isFlushingCheck()) {
        return;
      }
      //发泡中，不能开关盖
      if (this.magicBubble) {
        this.showToast(this.$i18n.t("toast.bubblingHoldOn"));
        return;
      }
      //喷嘴自洁，不能开关盖
      if (this.sprayWash) {
        this.showToast(this.$i18n.t("toast.sprayWashingHoldOn"));
        return;
      }
      //盖圈动作中，不能重复操作开关盖
      if (this.coverOpening) {
        if (this.ringOpening) {
          this.showToast(this.$i18n.t("toast.coverRingOpeningHoldOn"));
        } else {
          this.showToast(this.$i18n.t("toast.coverOpeningHoldOn"));
        }
        return;
      } else if (this.coverClosing) {
        if (this.ringClosing) {
          this.showToast(this.$i18n.t("toast.coverRingClosingHoldOn"));
        } else {
          this.showToast(this.$i18n.t("toast.coverClosingHoldOn"));
        }
        return;
      } else if (this.ringOpening) {
        this.showToast(this.$i18n.t("toast.ringOpeningHoldOn"));
        return;
      } else if (this.ringClosing) {
        this.showToast(this.$i18n.t("toast.ringClosingHoldOn"));
        return;
      }
      // if (this.coverPlateStatus && this.seatRingStatus) {
      //   //翻圈翻盖中，不能开关盖
      //   this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
      //   return;
      // } else if (this.coverPlateStatus) {
      //   //翻盖中，不能开关盖
      //   this.showToast(this.$i18n.t("toast.coveringHoldOn"));
      //   return;
      // } else if (this.seatRingStatus) {
      //   //翻圈中，不能开关盖
      //   this.showToast(this.$i18n.t("toast.ringingHoldOn"));
      //   return;
      // }
    },
    //点击座圈按钮
    clickRing: function () {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      if (this.ring) {
        this.coverPlateStatus = false;
        this.seatRingStatus = true;

        this.coverClosing = false;
        this.ringClosing = true;
        this.coverOpening = false;
        this.ringOpening = false;
      } else {
        if (this.cover) {
          this.coverPlateStatus = false;
          this.seatRingStatus = true;

          this.coverClosing = false;
          this.ringClosing = false;
          this.coverOpening = false;
          this.ringOpening = true;
        } else {
          this.coverPlateStatus = true;
          this.seatRingStatus = true;

          this.coverClosing = false;
          this.ringClosing = false;
          this.coverOpening = true;
          this.ringOpening = true;
        }
      }
      this.ring = !this.ring;
      //如果是开启座圈，那么本地的盖板要先开启
      if (this.ring) {
        this.cover = true;
      }
      let val = this.ring ? 1 : 0;
      this.prepareSendProperty({ seatRing: { on: val } });
    },
    clickRingDisable() {
      if (this.isFasterClick()) return;
      //着坐中，不能开关圈
      if (this.seatStatus) {
        this.showToast(this.$i18n.t("toast.pleaseStandUp"));
        return;
      }
      //冲水中，不能开关盖
      if (this.isFlushingCheck()) {
        return;
      }
      //发泡中，不能开关盖
      if (this.magicBubble) {
        this.showToast(this.$i18n.t("toast.bubblingHoldOn"));
        return;
      }
      //喷嘴自洁中，不能开关盖
      if (this.sprayWash) {
        this.showToast(this.$i18n.t("toast.sprayWashingHoldOn"));
        return;
      }
      //盖圈动作中，不能重复操作开关盖
      if (this.coverOpening) {
        if (this.ringOpening) {
          this.showToast(this.$i18n.t("toast.coverRingOpeningHoldOn"));
        } else {
          this.showToast(this.$i18n.t("toast.coverOpeningHoldOn"));
        }
        return;
      } else if (this.coverClosing) {
        if (this.ringClosing) {
          this.showToast(this.$i18n.t("toast.coverRingClosingHoldOn"));
        } else {
          this.showToast(this.$i18n.t("toast.coverClosingHoldOn"));
        }
        return;
      } else if (this.ringOpening) {
        this.showToast(this.$i18n.t("toast.ringOpeningHoldOn"));
        return;
      } else if (this.ringClosing) {
        this.showToast(this.$i18n.t("toast.ringClosingHoldOn"));
        return;
      }
      // if (this.coverPlateStatus && this.seatRingStatus) {
      //   //翻圈翻盖中，不能开关盖
      //   this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
      //   return;
      // } else if (this.coverPlateStatus) {
      //   //翻盖中，不能开关盖
      //   this.showToast(this.$i18n.t("toast.coveringHoldOn"));
      //   return;
      // } else if (this.seatRingStatus) {
      //   //翻圈中，不能开关盖
      //   this.showToast(this.$i18n.t("toast.ringingHoldOn"));
      //   return;
      // }
    },
    //点击大冲按钮
    clickFlush: function () {
      if (this.isFasterClick()) return;

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      this.flush = !this.flush;
      if (this.flush) {
        this.stopBubbleTimer();
      }
      let val = this.flush ? 1 : 0;
      this.prepareSendProperty({ bigflushSwitch: { on: val } });
    },
    clickFlushDisable() {
      if (this.isFasterClick()) return;
      //小冲中，不能点击冲水
      if (this.smallFlush) {
        this.showToast(this.$i18n.t("toast.flushingCantDo"));
        return;
      }
      //大冲中，不能点击冲水
      if (this.flush) {
        this.showToast(this.$i18n.t("toast.flushingAutoClose"));
        return;
      }
      //冲洗模式中，不能点击冲水
      if (this.isWashModeFlushUnable) {
        this.showToast(this.$i18n.t("toast.washingCantDo"));
        return;
      }
      //光照理疗中，不能点击冲水
      if (this.isLightTreatMode) {
        this.showToast(this.$i18n.t("toast.lightTreatingCantDo"));
        return;
      }
      //暖风模式中，不能点击冲水
      if (this.warmWindMode) {
        this.showToast(this.$i18n.t("toast.warmingHoldOn"));
        return;
      }
      //水位未满
      if (!this.waterLevel) {
        this.showToast(this.$i18n.t("toast.waterLevelHoldOn"));
      }

      if (this.coverPlateStatus && this.seatRingStatus) {
        //翻盖翻圈中，不能点击冲水
        this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
        return;
      } else if (this.coverPlateStatus) {
        //翻盖中，不能点击冲水
        this.showToast(this.$i18n.t("toast.coveringHoldOn"));
        return;
      } else if (this.seatRingStatus) {
        //翻圈中，不能点击冲水
        this.showToast(this.$i18n.t("toast.ringingHoldOn"));
        return;
      }

      //发泡中，不能点击冲水
      // if (this.magicBubble) {
      //   this.showToast(this.$i18n.t("toast.bubblingHoldOn"));
      //   return;
      // }
      //喷嘴自洁中，不能点击冲水
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击冲水
      // if (this.isSprayDisassembly()) return;
    },
    //点击小冲按钮
    clickSmallFlush: function () {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      this.smallFlush = !this.smallFlush;
      if (this.smallFlush) {
        this.stopBubbleTimer();
      }
      let val = this.smallFlush ? 1 : 0;
      this.prepareSendProperty({ smallflushSwitch: { on: val } });
    },
    clickSmallFlushDisable() {
      if (this.isFasterClick()) return;
      //大冲中，不能点击冲水
      if (this.flush) {
        this.showToast(this.$i18n.t("toast.flushingCantDo"));
        return;
      }
      //小冲中，不能点击冲水
      if (this.smallFlush) {
        this.showToast(this.$i18n.t("toast.flushingAutoClose"));
        return;
      }
      //冲洗模式中，不能点击冲水
      if (this.isWashModeFlushUnable) {
        this.showToast(this.$i18n.t("toast.washingCantDo"));
        return;
      }
      //光照理疗中，不能点击冲水
      if (this.isLightTreatMode) {
        this.showToast(this.$i18n.t("toast.lightTreatingCantDo"));
        return;
      }
      //暖风模式中，不能点击冲水
      if (this.warmWindMode) {
        this.showToast(this.$i18n.t("toast.warmingHoldOn"));
        return;
      }
      //水位未满
      if (!this.waterLevel) {
        this.showToast(this.$i18n.t("toast.waterLevelHoldOn"));
      }

      if (this.coverPlateStatus && this.seatRingStatus) {
        //翻盖翻圈中，不能点击冲水
        this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
        return;
      } else if (this.coverPlateStatus) {
        //翻盖中，不能点击冲水
        this.showToast(this.$i18n.t("toast.coveringHoldOn"));
        return;
      } else if (this.seatRingStatus) {
        //翻圈中，不能点击冲水
        this.showToast(this.$i18n.t("toast.ringingHoldOn"));
        return;
      }

      //发泡中，不能点击冲水
      // if (this.magicBubble) {
      //   this.showToast(this.$i18n.t("toast.bubblingHoldOn"));
      //   return;
      // }
      //喷嘴自洁中，不能点击冲水
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击冲水
      // if (this.isSprayDisassembly()) return;
    },
    setMode: function (index, selected) {
      console.log("setMode(): index = ", index, "; seleceted = ", selected);
      this.power = selected;
      this.closeMode();
      switch (index) {
        case 101: //自动臀洗模式
          this.autoHipMode = selected;
          break;
        case 102: //自动妇洗模式
          this.autoWomanMode = selected;
          break;
        case 2: //臀洗模式
          this.hipMode = selected;
          break;
        case 3: //妇洗模式
          this.womanMode = selected;
          break;
        case 4: //烘干模式
          this.warmWindMode = selected;
          break;
        case 5: //助便强洗
          this.strongMode = selected;
          break;
        case 6: //喷嘴自洁
          this.sprayWash = selected;
          break;
        case 7: //坐浴模式
          this.sitWashMode = selected;
          break;
        case 8: //红光模式
          this.redLightMode = selected;
          break;
        case 9: //蓝光模式
          this.blueLightMode = selected;
          break;
        case 10: //红蓝光模式
          this.mixLightMode = selected;
          break;
      }
    },
    //先熄灭互斥模式所有按钮
    closeMode: function () {
      this.autoHipMode = false;
      this.autoWomanMode = false;
      this.hipMode = false;
      this.womanMode = false;
      this.warmWindMode = false;
      this.wideWash = false;
      this.moveWash = false;
      this.sprayWash = false;
      this.strongMode = false;
      this.sprayWash = false;
      this.sitWashMode = false;
      this.redLightMode = false;
      this.blueLightMode = false;
      this.mixLightMode = false;
    },

    //点击光照理疗模式
    clickLightTreatMode: function () {
      if (this.isFasterClick()) return;
      this.lightTreatModeSetDialogVisible = true;
    },
    clickLightTreatModeDisable() {
      if (this.isFasterClick()) return;
      //未着座，不能点击光照理疗
      if (!this.hasSeat()) return;
      //冲水中，不能点击光照理疗
      if (this.isFlushingCheck()) return;
      //冲洗模式中，不能点击光照理疗
      // if (this.isWashModeFlushUnable) {
      //   this.showToast(this.$i18n.t("toast.washingCantDo"));
      //   return;
      // }
      //暖风模式中，不能点击光照理疗
      // if (this.warmWindMode) {
      //   this.showToast(this.$i18n.t("toast.warmingHoldOn"));
      //   return;
      // }
    },
    //点击坐浴模式
    clickSitWashMode() {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      this.setMode(7, !this.sitWashMode);
      if (this.sitWashMode) {
        this.waterEffluent = false;
      }
      this.setShowCollapse();
      //切换喷嘴和水压
      this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
      this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
      let val = this.sitWashMode ? 104 : 200;
      this.prepareSendProperty({ toiletMode: { mode: val } });
    },
    clickSitWashModeDisable() {
      if (this.isFasterClick()) return;
      //流量异常，不能点击清洗模式
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      //进水超温，不能点击清洗模式
      if (this.isWaterIntoOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
        return;
      }
      //出水超温，不能点击清洗模式
      if (this.isWaterOutOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
        return;
      }
      //未着座，不能点击清洗模式
      if (!this.hasSeat()) return;
      //冲水中，不能点击清洗模式
      if (this.isFlushingCheck()) return;
      //发泡中，不能点击清洗模式
      if (this.isMagicBubble()) return;
      //喷嘴自洁中，不能点击清洗模式
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击清新模式
      if (this.isSprayDisassembly()) return;
    },
    //点击自动臀洗模式
    clickAutoHipMode() {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      this.setMode(101, !this.autoHipMode);
      if (this.autoHipMode) {
        this.waterEffluent = false;
      }
      this.setShowCollapse();
      this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
      this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
      if (this.autoHipMode) {
        this.prepareSendProperty({ toiletMode: { mode: 100 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    clickAutoHipModeDisable() {
      if (this.isFasterClick()) return;
      //流量异常，不能点击清洗模式
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      //进水超温，不能点击清洗模式
      if (this.isWaterIntoOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
        return;
      }
      //出水超温，不能点击清洗模式
      if (this.isWaterOutOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
        return;
      }
      //未着座，不能点击清洗模式
      if (!this.hasSeat()) return;
      //冲水中，不能点击清洗模式
      if (this.isFlushingCheck()) return;
      //发泡中，不能点击清洗模式
      if (this.isMagicBubble()) return;
      //喷嘴自洁中，不能点击清洗模式
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击清新模式
      if (this.isSprayDisassembly()) return;
    },
    //点击臀洗模式
    clickHipMode: function () {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.setMode(2, !this.hipMode);
      if (this.hipMode) {
        this.waterEffluent = false;
      }
      this.setShowCollapse();
      this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
      this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
      // let val = this.hipMode ? 1 : 200;
      // this.prepareSendProperty({ toiletMode: { mode: val } });
      if (this.hipMode) {
        this.prepareSendProperty({ toiletMode: { mode: 1 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    clickHipModeDisable() {
      if (this.isFasterClick()) return;
      //流量异常，不能点击清洗模式
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      //进水超温，不能点击清洗模式
      if (this.isWaterIntoOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
        return;
      }
      //出水超温，不能点击清洗模式
      if (this.isWaterOutOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
        return;
      }
      //未着座，不能点击清洗模式
      if (!this.hasSeat()) return;
      //冲水中，不能点击清洗模式
      if (this.isFlushingCheck()) return;
      //发泡中，不能点击清洗模式
      if (this.isMagicBubble()) return;
      //喷嘴自洁中，不能点击清洗模式
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击清洗模式
      if (this.isSprayDisassembly()) return;
    },
    //点击自动妇洗模式
    clickAutoWomanMode() {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();
      this.setMode(102, !this.autoWomanMode);
      if (this.autoWomanMode) {
        this.waterEffluent = false;
      }
      this.setShowCollapse();
      this.updateSprayPositionValue(this.womanNozzlePos); //切换到妇洗喷嘴位置
      this.updateWaterPressureValue(this.womanWaterGage); //切换到妇洗水压
      // let val = this.autoWomanMode ? 102 : 200;
      // this.prepareSendProperty({ toiletMode: { mode: val } });
      if (this.autoWomanMode) {
        this.prepareSendProperty({ toiletMode: { mode: 101 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    clickAutoWomanModeDisable() {
      if (this.isFasterClick()) return;
      //流量异常，不能点击清洗模式
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      //进水超温，不能点击清洗模式
      if (this.isWaterIntoOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
        return;
      }
      //出水超温，不能点击清洗模式
      if (this.isWaterOutOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
        return;
      }
      //未着座，不能点击清洗模式
      if (!this.hasSeat()) return;
      //冲水中，不能点击清洗模式
      if (this.isFlushingCheck()) return;
      //发泡中，不能点击清洗模式
      if (this.isMagicBubble()) return;
      //喷嘴自洁中，不能点击清洗模式
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击清洗模式
      if (this.isSprayDisassembly()) return;
    },
    //点击妇洗模式
    clickWomanMode: function () {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.setMode(3, !this.womanMode);
      if (this.womanMode) {
        this.waterEffluent = false;
      }
      this.setShowCollapse();
      this.updateSprayPositionValue(this.womanNozzlePos); //切换到妇洗喷嘴位置
      this.updateWaterPressureValue(this.womanWaterGage); //切换到妇洗水压
      // let val = this.womanMode ? 2 : 200;
      // this.prepareSendProperty({ toiletMode: { mode: val } });
      if (this.womanMode) {
        this.prepareSendProperty({ toiletMode: { mode: 2 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    clickWomanModeDisable() {
      if (this.isFasterClick()) return;
      //流量异常，不能点击清洗模式
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      //进水超温，不能点击清洗模式
      if (this.isWaterIntoOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
        return;
      }
      //出水超温，不能点击清洗模式
      if (this.isWaterOutOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
        return;
      }
      //未着座，不能点击清洗模式
      if (!this.hasSeat()) return;
      //冲水中，不能点击清洗模式
      if (this.isFlushingCheck()) return;
      //发泡中，不能点击清洗模式
      if (this.isMagicBubble()) return;
      //喷嘴自洁中，不能点击清洗模式
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击清洗模式
      if (this.isSprayDisassembly()) return;
    },
    //点击暖风模式卡片
    clickWarmWind: function () {
      console.log("clickWarmWind: 点击暖风按钮");
      if (this.isFasterClick()) return;
      //未着坐
      if (!this.hasSeat()) return;
      //发泡中
      if (this.isMagicBubble()) return;
      //喷嘴自洁中
      if (this.isSprayWash()) return;
      //喷嘴拆卸中
      if (this.isSprayDisassembly()) return;
      //冲水中
      if (this.isFlushingCheck()) return;

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.setMode(4, !this.warmWindMode);
      this.setHideCollapse(); //暖风开启时，隐藏折叠菜单
      // let val = this.warmWindMode ? 3 : 200;
      // this.prepareSendProperty({ toiletMode: { mode: val } });
      if (this.warmWindMode) {
        this.prepareSendProperty({ toiletMode: { mode: 3 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    //点击暖风模式
    clickWarmWindMode: function () {
      console.log("clickWarmWind: 点击暖风按钮");
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.setMode(4, !this.warmWindMode);
      this.setShowCollapse(); //暖风开启时，展开折叠菜单
      // this.setHideCollapse(); //暖风开启时，隐藏折叠菜单
      let val = this.warmWindMode ? 3 : 200;
      this.prepareSendProperty({ toiletMode: { mode: val } });
    },
    clickWarmWindModeDisable() {
      if (this.isFasterClick()) return;
      //未着坐
      if (!this.hasSeat()) return;
      //发泡中
      if (this.isMagicBubble()) return;
      //喷嘴自洁中
      if (this.isSprayWash()) return;
      //喷嘴拆卸中
      if (this.isSprayDisassembly()) return;
      //冲水中
      if (this.isFlushingCheck()) return;
    },
    //暖风提示
    clickTipBtn() {
      console.log("MainPage: 点击暖风Tip");
      if (this.isFasterClick()) return;
      //未着坐
      if (!this.hasSeat()) return;
      //发泡中
      if (this.isMagicBubble()) return;
      //喷嘴自洁中
      if (this.isSprayWash()) return;
      //喷嘴拆卸中
      if (this.isSprayDisassembly()) return;
      //冲水中
      if (this.isFlushingCheck()) return;

      this.getWarmWindTipPosition();
      this.closeTip = false;
      this.$refs.warmWindTip.openTip(this.$i18n.t("tip.warmWindTip"));
    },
    //点击助便强洗
    clickStrongMode: function () {
      if (this.isFasterClick()) return;
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.setMode(5, !this.strongMode);
      if (this.strongMode) {
        this.waterEffluent = false;
      }
      this.setShowCollapse();
      this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
      this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
      // let val = this.strongMode ? 100 : 200;
      // //待核对属性key
      // this.prepareSendProperty({ toiletMode: { mode: val } });
      if (this.strongMode) {
        this.prepareSendProperty({ toiletMode: { mode: 5 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    clickStrongModeDisable() {
      if (this.isFasterClick()) return;
      //流量异常，不能点击清洗模式
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      //进水超温，不能点击清洗模式
      if (this.isWaterIntoOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
        return;
      }
      //出水超温，不能点击清洗模式
      if (this.isWaterOutOverTempWarn) {
        this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
        return;
      }
      //未着座，不能点击清洗模式
      if (!this.hasSeat()) return;
      //冲水中，不能点击清洗模式
      if (this.isFlushingCheck()) return;
      //发泡中，不能点击清洗模式
      if (this.isMagicBubble()) return;
      //喷嘴自洁中，不能点击清洗模式
      if (this.isSprayWash()) return;
      //喷嘴拆卸中，不能点击清洗模式
      if (this.isSprayDisassembly()) return;
    },
    //开关宽幅强洗
    wideWashChange: function (newVal) {
      //未着坐
      if (!this.hasSeat()) {
        this.wideWash = !this.wideWash;
        return;
      }
      //冲水中
      if (this.isFlushingCheck()) {
        this.wideWash = !this.wideWash;
        return;
      }
      //自动清洗中
      if (this.autoHipMode || this.autoWomanMode) {
        this.wideWash = !this.wideWash;
        this.showToast(this.$i18n.t("toast.autoWashingCantWideWash"));
        return;
      }
      //臀洗中
      if (!this.hipMode) {
        this.wideWash = !this.wideWash;
        this.showToast(this.$i18n.t("toast.hipWashCanWideWash"));
        return;
      }

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.wideWash = newVal;
      let val = this.wideWash ? 1 : 0;
      this.prepareSendProperty({ wideWash: { on: val } });
    },

    //开关暖风模式的暖风移动
    warmMoveChangeForSitWashMode: function (newVal) {
      console.log(
        "warmMoveChangeForSitWashMode: this.warmMove = ",
        this.warmMove
      );
      if (this.isFasterClick()) {
        this.warmMove = !this.warmMove;
        return;
      }
      //未着座
      if (!this.hasSeat()) {
        this.warmMove = !this.warmMove;
        return;
      }
      //冲水中
      if (this.isFlushingCheck()) {
        this.warmMove = !this.warmMove;
        return;
      }
      //非舒适坐浴中
      if (!this.warmWindMode) {
        this.warmMove = !this.warmMove;
        this.showToast(this.$i18n.t("toast.warmWindCanWarmMove"));
        return;
      }

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.warmMove = newVal;
      let val = this.warmMove ? 1 : 0;
      this.prepareSendProperty({ control: { warmMove: val } });
    },

    //开关舒适坐浴的移动按摩
    moveWashChangeForSitWashMode: function (newVal) {
      console.log(
        "moveWashChangeForSitWashMode: this.moveWash = ",
        this.moveWash
      );
      if (this.isFasterClick()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //未着座
      if (!this.hasSeat()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //冲水中
      if (this.isFlushingCheck()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //非舒适坐浴中
      if (!this.sitWashMode) {
        this.moveWash = !this.moveWash;
        this.showToast(this.$i18n.t("toast.sitWashCanMoveWash"));
        return;
      }

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.moveWash = newVal;
      let val = this.moveWash ? 1 : 0;
      this.prepareSendProperty({ moveWash: { on: val } });
    },

    //开关助便强洗的移动按摩
    moveWashChangeForStrongMode: function (newVal) {
      console.log(
        "moveWashChangeForStrongMode: this.moveWash = ",
        this.moveWash
      );
      if (this.isFasterClick()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //未着座
      if (!this.hasSeat()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //冲水中
      if (this.isFlushingCheck()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //非助便强洗中
      if (!this.strongMode) {
        this.moveWash = !this.moveWash;
        this.showToast(this.$i18n.t("toast.strongWashCanMoveWash"));
        return;
      }

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.moveWash = newVal;
      let val = this.moveWash ? 1 : 0;
      this.prepareSendProperty({ moveWash: { on: val } });
    },
    clickMoveWashDisable() {
      this.showToast(this.$i18n.t("toast.nozzleNotReadyCantUse"));
    },

    //开关移动按摩
    moveWashChange: function (newVal) {
      if (this.isFasterClick()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //未着坐
      if (!this.hasSeat()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //冲水中
      if (this.isFlushingCheck()) {
        this.moveWash = !this.moveWash;
        return;
      }
      //非妇洗中
      if (!this.womanMode) {
        this.moveWash = !this.moveWash;
        this.showToast(this.$i18n.t("toast.womanWashCanMoveWash"));
        return;
      }

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.moveWash = newVal;
      let val = this.moveWash ? 1 : 0;
      this.prepareSendProperty({ moveWash: { on: val } });
    },
    //点击魔力泡
    clickMagicalBubble: function () {
      if (this.isFasterClick()) return;
      //流量异常中
      if (this.isFlowFault) {
        this.showToast(this.$i18n.t("toast.flowFaultCantDo"));
        return;
      }
      if (this.coverPlateStatus && this.seatRingStatus) {
        //翻圈翻盖中，不能发泡
        this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
        return;
      } else if (this.coverPlateStatus) {
        //翻盖中，不能发泡
        this.showToast(this.$i18n.t("toast.coveringHoldOn"));
        return;
      } else if (this.seatRingStatus) {
        //翻圈中，不能发泡
        this.showToast(this.$i18n.t("toast.ringingHoldOn"));
        return;
      }
      // //进水超温，不能点击清洗模式
      // if( this.isWaterIntoOverTempWarn){
      //   this.showToast(this.$i18n.t("toast.waterIntoOverTempWarCantDo"));
      //   return;
      // }
      // //出水超温，不能点击清洗模式
      // if( this.isWaterIntoOverTempWarn){
      //   this.showToast(this.$i18n.t("toast.waterOutOverTempWarCantDo"));
      //   return;
      // }

      //冲洗模式中
      if (this.isWashMode) {
        this.showToast(this.$i18n.t("toast.washingHoldOn"));
        return;
      }
      //暖风模式中
      if (this.warmWindMode) {
        this.showToast(this.$i18n.t("toast.warmingHoldOn"));
        return;
      }
      //冲水中
      if (this.isFlushingCheck()) return;
      //喷嘴自洁中
      if (this.isSprayWash()) return;
      //喷嘴拆卸中
      // if (this.isSprayDisassembly()) return;

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      //发泡中
      if (this.bubbleIsLocking) {
        this.showToast(this.$i18n.t("toast.bubblingCantBubble"));
        return;
      } else {
        this.startBubbleTimer();
      }
      this.magicBubble = !this.magicBubble;
      let val = this.magicBubble ? 1 : 0;
      this.prepareSendProperty({ control: { magicFoaming: val } });
    },
    //点击光触媒除臭模式
    clickDeodorize() {
      this.gotoDeodorizeSetting();
    },
    //点击喷嘴自洁
    clickSprayWash: function () {
      if (this.isFasterClick()) return;
      //着座时，不能开启喷嘴自洁
      if (this.seatStatus) {
        this.showToast(this.$i18n.t("toast.pleaseStandUp"));
        return;
      }
      //魔力泡时，不能开启喷嘴自洁
      if (this.isMagicBubble()) return;
      //大小冲时，不能开启喷嘴自洁
      if (this.isFlushingCheck()) return;
      //拆卸时，不能开启喷嘴自洁
      // if (this.isSprayDisassembly()) return;
      //翻盖翻圈中，不能开启喷嘴自洁
      // if (this.coverPlateStatus || this.seatRingStatus) {
      //   this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
      //   return;
      // }
      //盖圈动作中，不能重复操作开关盖
      if (this.coverOpening) {
        if (this.ringOpening) {
          this.showToast(this.$i18n.t("toast.coverRingOpeningHoldOn"));
        } else {
          this.showToast(this.$i18n.t("toast.coverOpeningHoldOn"));
        }
        return;
      } else if (this.coverClosing) {
        if (this.ringClosing) {
          this.showToast(this.$i18n.t("toast.coverRingClosingHoldOn"));
        } else {
          this.showToast(this.$i18n.t("toast.coverClosingHoldOn"));
        }
        return;
      } else if (this.ringOpening) {
        this.showToast(this.$i18n.t("toast.ringOpeningHoldOn"));
        return;
      } else if (this.ringClosing) {
        this.showToast(this.$i18n.t("toast.ringClosingHoldOn"));
        return;
      }

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      // this.beforeChangeStatusSendProperty();

      //喷嘴自洁锁开启时，不能开启喷嘴自洁
      if (this.sprayWashIsLocking) {
        this.showToast(this.$i18n.t("toast.sprayWashCantSprayWash"));
        return;
      } else {
        if (this.sprayWash) {
          this.startSprayWashTimer();
        }
      }
      this.sprayWash = !this.sprayWash;
      // let val = this.sprayWash ? 103 : 200;
      // this.prepareSendProperty({ toiletMode: { mode: val } });
      // let val = this.sprayWash ? 1 : 0;
      // this.prepareSendProperty({ control: { cleaningSwitch: val } });
      if (this.sprayWash) {
        this.prepareSendProperty({ toiletMode: { mode: 102 } });
      } else {
        this.prepareSendProperty({ stop: { action: 0 } });
      }
    },
    //点击喷嘴拆卸
    clickSprayDisassemble: function () {
      if (this.isFasterClick()) return;
      //着座时，不能开启喷嘴拆卸
      if (this.seatStatus) {
        this.showToast(this.$i18n.t("toast.pleaseStandUp"));
        return;
      }
      //关盖时，不能开启喷嘴拆卸
      if (!this.cover) {
        this.showToast(this.$i18n.t("toast.pleaseOpenCover"));
        return;
      }
      //关圈时，不能开启喷嘴拆卸
      if (!this.ring) {
        this.showToast(this.$i18n.t("toast.pleaseOpenRing"));
        return;
      }
      //盖圈动作时，不能开启喷嘴拆卸
      if (this.coverPlateStatus || this.seatRingStatus) {
        this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
        return;
      }
      //大小冲时，不能开启喷嘴拆卸
      if (this.isFlushingCheck()) return;
      //喷嘴自洁时，不能开启喷嘴拆卸
      if (this.isSprayWash()) return;

      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      // this.beforeChangeStatusSendProperty();
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      //喷嘴自洁锁开启时，不能开启喷嘴自洁
      if (this.sprayWashIsLocking) {
        this.showToast(this.$i18n.t("toast.sprayWashingHoldOn"));
        return;
      }
      this.sprayDisassemble = !this.sprayDisassemble;
      let val = this.sprayDisassemble ? 1 : 0;
      this.prepareSendProperty({ control: { nozzleDisassembly: val } });
    },
    //点击疏通模式
    clickDredgeMode: function () {
      if (this.isFasterClick()) return;
      //着座时，不能开启疏通模式
      if (this.seatStatus) {
        this.showToast(this.$i18n.t("toast.pleaseStandUp"));
        return;
      }
      //关盖时，不能开启疏通模式
      if (!this.cover) {
        this.showToast(this.$i18n.t("toast.pleaseOpenCover"));
        return;
      }
      //翻盖翻圈时，不能开启疏通模式
      if (this.coverPlateStatus || this.seatRingStatus) {
        this.showToast(this.$i18n.t("toast.coveringRingingHoldOn"));
        return;
      }
      //先更新状态，避免一直点击时，因为3秒限制造成收到的状态一直未被更新，
      this.beforeChangeStatusSendProperty();

      this.dredgeMode = !this.dredgeMode;
      let val = this.dredgeMode ? 1 : 0;
      this.prepareSendProperty({ control: { dredging: val } });
    },
    //点击加液盒
    clickFillingBox: function () {
      if (this.isFasterClick()) return;
      //满液位时，不能添加发泡剂
      // if (this.foamLeftState === 2) {
      //   this.showToast(this.$i18n.t("toast.bubbleEnoughCantFill"));
      //   return;
      // }
      if (!this.ring || this.seatRingStatus) {
        this.showToast(this.$i18n.t("toast.pleaseOpenRingFirst"));
        return;
      }
      this.fillingBox = !this.fillingBox;
      let val = this.fillingBox ? 1 : 0;
      this.prepareSendProperty({ control: { filingBox: val } });
    },
    //点击用户1弹框
    clickUser1: function () {
      console.log("clickUser1");
      this.user1DialogShow = true;
    },
    //点击用户2弹框
    clickUser2: function () {
      console.log("clickUser2");
      this.user2DialogShow = true;
    },
    //点击“使用用户1”
    clickUseUser1Param: function () {
      console.log("click use user1");
      this.user1 = 1;
      sendPropertyWithCallback(
        { control: { user1: this.user1 } },
        "sendUser1Enable"
      );
    },
    //发送“使用用户1”指令后的回调
    sendUser1EnableCallback(data) {
      if (
        data !== undefined &&
        data.errcode != undefined &&
        data.errcode === 0
      ) {
        // console.log("使用用户1 吐司");
        this.showToast(this.$i18n.t("toast.hasUseUser1"));
      } else {
        // this.showToast(this.$i18n.t("toast.hasUseUser1"));
      }
    },
    //点击“保存用户1”
    clickSaveUser1Param: function () {
      console.log("click save user1");
      this.user1 = 2;
      sendPropertyWithCallback(
        { control: { user1: this.user1 } },
        "sendUser1Save"
      );
    },
    //发送“保存用户1”指令后的回调
    sendUser1SaveCallback(data) {
      if (
        data !== undefined &&
        data.errcode != undefined &&
        data.errcode === 0
      ) {
        // console.log("保存用户1 吐司");
        this.showToast(this.$i18n.t("toast.hasSaveUser1"));
      } else {
        // this.showToast(this.$i18n.t("toast.hasUseUser1"));
      }
    },
    //点击“使用用户2”
    clickUseUser2Param: function () {
      console.log("click use user2");
      this.user2 = 1;
      sendPropertyWithCallback(
        { control: { user2: this.user2 } },
        "sendUser2Enable"
      );
    },
    //发送“使用用户2”指令后的回调
    sendUser2EnableCallback(data) {
      if (
        data !== undefined &&
        data.errcode != undefined &&
        data.errcode === 0
      ) {
        // console.log("使用用户2 吐司");
        this.showToast(this.$i18n.t("toast.hasUseUser2"));
      } else {
        // this.showToast(this.$i18n.t("toast.hasUseUser1"));
      }
    },
    //点击“保存用户2”
    clickSaveUser2Param: function () {
      console.log("click save user2");
      this.user2 = 2;
      sendPropertyWithCallback(
        { control: { user2: this.user2 } },
        "sendUser2Save"
      );
    },
    //发送“保存用户2”指令后的回调
    sendUser2SaveCallback(data) {
      if (
        data !== undefined &&
        data.errcode != undefined &&
        data.errcode === 0
      ) {
        // console.log("保存用户2 吐司");
        this.showToast(this.$i18n.t("toast.hasSaveUser2"));
      } else {
        // this.showToast(this.$i18n.t("toast.hasUseUser1"));
      }
    },
    //点击展开更多
    clickMoreList: function () {
      if (this.isFasterClick()) return;
      this.showMoreList = !this.showMoreList;
    },
    clickSlider: function () {},
    //非宽幅清洗中，不能调节幅度
    notWideWashUnableRange() {
      if (!this.wideWash) {
        this.showToast(this.$i18n.t("toast.notWideWashCantRange"));
      }
    },
    //宽幅清洗和暖风模式中，不能调节喷嘴档位
    wideWashUnableNozzlePos() {
      if (this.wideWash) {
        //宽幅强洗
        this.showToast(this.$i18n.t("toast.wideWashCantSetNozzlePos"));
      } else if (this.warmWindMode) {
        //暖风模式
        this.showToast(this.$i18n.t("toast.warmWindCantSetNozzlePos"));
      } else if (!this.waterEffluent) {
        //自动模式的暖风阶段，暂时只能用不出水判断
        this.showToast(this.$i18n.t("toast.waterEffluentCantSetNozzlePos"));
      }
    },
    //暖风模式中，不能调节水压
    warmWindUnableWaterPress() {
      if (this.warmWindMode) {
        //暖风模式
        this.showToast(this.$i18n.t("toast.warmWindCantSetWaterPress"));
      } else if (!this.waterEffluent) {
        //自动模式的暖风阶段，自动模式的暖风阶段暂时只能用不出水判断
        this.showToast(this.$i18n.t("toast.waterEffluentCantSetWaterPress"));
      }
    },
    //四季温感开启，不能调节水温
    tempSensorUnableWaterTemp() {
      this.showToast(this.$i18n.t("toast.tempSensorCantSetWaterTemp"));
    },
    //四季温感开启，不能调节座温
    tempSensorUnableSeatTemp() {
      this.showToast(this.$i18n.t("toast.tempSensorCantSetWaterTemp"));
    },
    //发泡计时
    startBubbleTimer() {
      if (this.bubbleTimer != null) {
        clearTimeout(this.bubbleTimer);
      }
      this.bubbleIsLocking = true;
      this.bubbleTimer = setTimeout(() => {
        this.bubbleIsLocking = false;
      }, 60000);
    },
    //停止发泡计时
    stopBubbleTimer() {
      this.bubbleIsLocking = false;
      if (this.bubbleTimer != null) {
        clearTimeout(this.bubbleTimer);
      }
    },
    //喷嘴自洁计时
    startSprayWashTimer() {
      // console.log("喷嘴自洁计时开始");
      if (this.sprayWashTimer != null) {
        clearTimeout(this.sprayWashTimer);
      }
      this.sprayWashIsLocking = true;
      this.sprayWashTimer = setTimeout(() => {
        this.sprayWashIsLocking = false;
        // console.log("喷嘴自洁计时结束");
      }, 10000);
    },
    //在规定时间内锁住冲水按钮（不让冲水）
    // lockFlushClick: function () {
    //   if (this.flushClickLockTimer != null) {
    //     clearTimeout(this.flushClickLockTimer);
    //   }
    //   this.flushClickLocking = true;
    //   this.flushClickLockTimer = setTimeout(() => {
    //     this.flushClickLocking = false;
    //   }, 5000);
    // },
    //发送指令前用缓存更新数据（注意：是在本地状态更改前调用）
    beforeChangeStatusSendProperty: function () {
      this.updateUIFromData();
    },
    //发送指令
    prepareSendProperty: function (jsObject) {
      if (this.uiLockTimer != null) {
        clearTimeout(this.uiLockTimer);
      }
      this.uiIsLocking = true;
      this.uiLockTimer = setTimeout(() => {
        this.uiIsLocking = false;
        console.log("三秒后刷新");
        if (!this.seatRingStatus && !this.coverPlateStatus) {
          // this.updateUIFromData();
          getDevInfoAll();
        } else {
          //用户全部缓存数据刷新
          // this.updateUIFromData();
          //处于翻盖中或者翻圈中，只更新翻盖中或翻圈中等少数状态
          this.updateCoverOrRingPlateUI();
        }
      }, 3000);
      sendProperty(jsObject);
    },
    hasSeat: function () {
      if (!this.seatStatus) {
        this.showToast(this.$i18n.t("toast.pleaseSit"));
        return false;
      }
      return true;
    },
    isFlushingCheck: function () {
      if (this.flush || this.smallFlush) {
        this.showToast(this.$i18n.t("toast.flushingHoldOn"));
        return true;
      }
      return false;
    },
    isMagicBubble: function () {
      if (this.magicBubble) {
        this.showToast(this.$i18n.t("toast.bubblingHoldOn"));
        return true;
      }
      return false;
    },
    isSprayWash: function () {
      if (this.sprayWash) {
        this.showToast(this.$i18n.t("toast.sprayWashingHoldOn"));
        return true;
      }
      return false;
    },
    //喷嘴拆卸中提示
    isSprayDisassembly: function () {
      if (this.sprayDisassemble) {
        this.showToast(this.$i18n.t("toast.sprayDisassemblyHoldOn"));
        return true;
      }
      return false;
    },

    //使用stutus服务下所有属性值刷新界面
    updateUIByStatusService(data) {
      if (this.tStatusData != null) {
        this.tStatusData.data = data;
        this.updateUI(this.tStatusData);
      }
    },
    //使用control服务下所有属性值刷新界面
    updateUIByControlService(data) {
      if (this.controlData != null) {
        this.controlData.data = data;
        this.updateUI(this.controlData);
      }
    },
    //使用gear服务下所有属性值刷新界面
    updateUIByGearService(data) {
      if (this.toiletGearData != null) {
        this.toiletGearData.data = data;
        this.updateUI(this.toiletGearData);
      }
    },
    //使用setting服务下素有属性值刷新界面
    updateUIBySettingService(data) {
      if (this.settingData != null) {
        this.settingData.data = data;
      }
    },

    // 更新滑块的值
    // 更新幅度值
    updateMoveRangeValue: function (index) {
      if (index > 4 || index < 0) return;
      this.moveRangeValue = index * 25;
    },
    //更新喷嘴位置值
    updateSprayPositionValue: function (index) {
      if (index > 4 || index < 0) return;
      this.sprayPositionValue = index * 25;
      this.oldSprayPositionValue = this.sprayPositionValue;
    },
    //更新水压值
    updateWaterPressureValue: function (index) {
      if (index > 4 || index < 0) return;
      this.waterPressureValue = Math.round((index / 4.0) * 100);
    },
    //更新水温值
    updateWaterTemperatureValue: function (index) {
      if (index > 5 || index < 0) return;
      this.waterTemperatureValue = index * 20;
      this.oldWaterTemperatureValue = this.waterTemperatureValue;
    },
    //更新座温值
    updateSeatTemperatureValue: function (index) {
      if (index > 5 || index < 0) return;
      this.seatTemperatureValue = index * 20;
      this.oldSeatTemperatureValue = this.seatTemperatureValue;
    },
    //更新风温值
    updateWindTemperatureValue: function (index) {
      if (index > 3 || index < 0) return;
      this.windTemperatureValue = Math.round(index * 33.33);
    },
    //更新风速值
    updateWindSpeedValue: function (index) {
      if (index > 2 || index < 0) return;
      this.windSpeedValue = Math.round(index * 50);
    },

    // 发送滑块的值
    //下发喷嘴压力属性(向设备发送喷嘴压力属性值)
    sendSprayPositionSlideValue(value) {
      //点击喷嘴位置时，主动更新宽幅强洗
      this.updateWideWashUI();

      this.sprayPositionValue = parseFloat(value);
      var index = Math.round(this.sprayPositionValue / 25);
      var oldIndex = Math.round(this.oldSprayPositionValue / 25);
      if (index > oldIndex + 1 || index < oldIndex - 1) {
        this.showToast(this.$i18n.t("toast.onceChangeOneLevel"));
      }
      if (index > oldIndex) {
        index = oldIndex + 1;
        this.sprayPositionValue = this.oldSprayPositionValue + 25;
        this.oldSprayPositionValue = this.sprayPositionValue;
      } else if (index < oldIndex) {
        index = oldIndex - 1;
        this.sprayPositionValue = this.oldSprayPositionValue - 25;
        this.oldSprayPositionValue = this.sprayPositionValue;
      }
      var data;
      if (this.womanMode || this.autoWomanMode) {
        this.womanNozzlePos = index;
        data = { toiletGear: { womanNozzlePos: index } }; //妇洗喷嘴位置
      } else {
        this.hipNozzlePosition = index;
        data = { toiletGear: { hipNozzlePos: index } }; //待定：自动和臀洗都用臀洗喷嘴位置hipNozzlePosition
      }
      this.prepareSendProperty(data);
    },
    //下发幅度属性(向设备发送幅度属性值)
    sendRangeSlideValue(value) {
      this.moveRangeValue = parseFloat(value);
      var index = Math.round(this.moveRangeValue / 25);
      let data = { toiletGear: { wideWashingRange: index } }; //需要校对属性key
      this.prepareSendProperty(data);
    },
    //下发水压属性(向设备发送水压属性值)
    sendWaterPresssureSlideValue(value) {
      this.waterPressureValue = parseFloat(value);
      let val = Math.round(this.waterPressureValue / 25);
      var data;
      if (this.womanMode || this.autoWomanMode) {
        this.womanWaterGage = val;
        data = { toiletGear: { womanWaterGage: val } }; // 妇洗水压
      } else {
        this.hipWaterGage = val;
        data = { toiletGear: { hipWaterGage: val } }; //自动和臀洗都用臀洗水压
      }
      this.prepareSendProperty(data);
    },
    //下发水温属性(向设备发送水温属性值)
    sendWaterTemperatureSlideValue(value) {
      if (this.settingData != null && this.settingData.data.tempSensor === 1) {
        this.waterTemperatureValue = this.oldWaterTemperatureValue;
        this.showToast(this.$i18n.t("toast.unableWhenAutoTempOn"));
        return;
      }
      this.waterTemperatureValue = parseFloat(value);
      var index = Math.round(this.waterTemperatureValue / 20);
      let data = { waterGear: { gear: index } };
      this.prepareSendProperty(data);
    },
    //下发座温属性(向设备发送座温属性值)
    sendSeatTemperatureSlideValue(value) {
      if (this.settingData != null && this.settingData.data.tempSensor === 1) {
        this.seatTemperatureValue = this.oldSeatTemperatureValue;
        this.showToast(this.$i18n.t("toast.unableWhenAutoTempOn"));
        return;
      }
      this.seatTemperatureValue = parseFloat(value);
      var index = Math.round(this.seatTemperatureValue / 20);
      let data = { seatGear: { gear: index } };
      this.prepareSendProperty(data);
    },
    //下发风温属性(向设备发送风温属性值)
    sendWindTemperatureSlideValue(value) {
      this.windTemperatureValue = parseFloat(value);
      var index = Math.round(this.windTemperatureValue / 33.33);
      let data = { windGear: { gear: index } };
      this.prepareSendProperty(data);
    },
    //下发风速属性（向设备发送风速属性值）
    sendWindSpeedSlideValue(value) {
      this.windSpeedValue = parseFloat(value);
      var index = Math.round(this.windSpeedValue / 50);
      let data = { toiletGear: { windSpeed: index } };
      this.prepareSendProperty(data);
    },

    //用缓存更新UI
    updateUIFromData: function () {
      console.log("用缓存更新UI");
      if (this.stopData != null) {
        this.updateUI(this.stopData);
      }
      if (this.seatStatusData != null) {
        this.updateUI(this.seatStatusData);
      }
      if (this.toiletModeData != null) {
        this.updateUI(this.toiletModeData);
      }
      if (this.wideWashData != null) {
        this.updateUI(this.wideWashData);
      }
      if (this.moveWashData != null) {
        this.updateUI(this.moveWashData);
      }
      if (this.smallflushSwitchData != null) {
        this.updateUI(this.smallflushSwitchData);
      }
      if (this.bigflushSwitchData != null) {
        this.updateUI(this.bigflushSwitchData);
      }
      if (this.seatRingData != null) {
        this.updateUI(this.seatRingData);
      }
      if (this.filpSwitchData != null) {
        this.updateUI(this.filpSwitchData);
      }
      if (this.windGearData != null) {
        this.updateUI(this.windGearData);
      }
      if (this.waterGearData != null) {
        this.updateUI(this.waterGearData);
      }
      if (this.seatGearData != null) {
        this.updateUI(this.seatGearData);
      }
      if (this.filterElementData != null) {
        this.updateUI(this.filterElementData);
      }
      if (this.tStatusData != null) {
        this.updateUI(this.tStatusData);
      }
      if (this.toiletStatusData != null) {
        this.updateUI(this.toiletStatusData);
      }
      if (this.controlData != null) {
        this.updateUI(this.controlData);
      }
      if (this.toiletGearData != null) {
        this.updateUI(this.toiletGearData);
      }
      if (this.deviceAlarmData != null) {
        this.updateUI(this.deviceAlarmData);
      }
      if (this.faultDetectionData != null) {
        this.updateUI(this.faultDetectionData);
      }
      if (this.settingData != null) {
        this.updateUI(this.settingData);
      }
    },
    //处理属性上报事件(处理设备上传的属性事件)
    propertiesListener: function (data) {
      //先缓存数据
      if (data.sid === undefined || data.data === undefined) return;
      if (data.sid === "stop") {
        this.stopData = data;
      } else if (data.sid === "seatStatus") {
        this.seatStatusData = data;
      } else if (data.sid === "toiletMode") {
        this.toiletModeData = data;
      } else if (data.sid === "wideWash") {
        this.wideWashData = data;
      } else if (data.sid === "moveWash") {
        this.moveWashData = data;
      } else if (data.sid === "smallflushSwitch") {
        this.smallflushSwitchData = data;
      } else if (data.sid === "bigflushSwitch") {
        this.bigflushSwitchData = data;
      } else if (data.sid === "seatRing") {
        this.seatRingData = data;
      } else if (data.sid === "filpSwitch") {
        this.filpSwitchData = data;
      } else if (data.sid === "windGear") {
        this.windGearData = data;
      } else if (data.sid === "waterGear") {
        this.waterGearData = data;
      } else if (data.sid === "seatGear") {
        this.seatGearData = data;
      } else if (data.sid === "filterElement") {
        this.filterElementData = data;
      } else if (data.sid === "tStatus") {
        this.tStatusData = data;
      } else if (data.sid === "toiletStatus") {
        this.toiletStatusData = data;
      } else if (data.sid === "control") {
        this.controlData = data;
      } else if (data.sid === "toiletGear") {
        this.toiletGearData = data;
      } else if (data.sid === "deviceAlarm") {
        this.deviceAlarmData = data;
      } else if (data.sid === "faultDetection") {
        this.faultDetectionData = data;
      } else if (data.sid === "setting") {
        this.settingData = data;
      }
      //如果UI更新被锁定，就暂时无法更新UI
      if (this.uiIsLocking) {
        return;
      }
      //更新UI
      this.updateUI(data);
    },
    //更新UI
    updateUI: function (data) {
      if (data.sid === "stop") {
        //“一键关闭”switch不接收上报的状态，只用于下发
      } else if (data.sid === "seatStatus") {
        //着坐状态
        if (data.data.status !== undefined) {
          this.seatStatus = data.data.status === 1;
        }
      } else if (data.sid === "toiletMode") {
        if (data.data.mode !== undefined) {
          console.log("updateUI(): toiletMode: mode = ", data.data.mode);
          // //喷嘴自洁关闭时，要开启无法点击的定时器
          if (this.sprayWash && data.data.mode !== 102) {
            this.startSprayWashTimer();
          }
          let mode = 1;
          switch (data.data.mode) {
            case 200: //0-待机模式
              this.setMode(0, false);
              break;
            case 1: //1-臀洗模式
              this.setMode(2, true);
              // this.setShowCollapse(); //臀洗开启时，显示折叠菜单
              this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
              this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
              break;
            case 2: //2-妇洗模式
              this.setMode(3, true);
              // this.setShowCollapse(); //妇洗开启时，显示折叠菜单
              this.updateSprayPositionValue(this.womanNozzlePos); //切换到妇洗喷嘴位置
              this.updateWaterPressureValue(this.womanWaterGage); //切换到妇洗水压
              break;
            case 3: //3-暖风模式
              this.setMode(4, true);
              break;
            case 5: //5-助便强洗模式
              this.setMode(5, true);
              // this.setShowCollapse(); //臀洗开启时，显示折叠菜单
              this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
              this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
              break;
            case 100: //100-自动臀洗模式
              this.setMode(101, true);
              // this.setShowCollapse(); //臀洗开启时，显示折叠菜单
              this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
              this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
              break;
            case 101: //101-自动妇洗模式
              this.setMode(102, true);
              // this.setShowCollapse(); //妇洗开启时，显示折叠菜单
              this.updateSprayPositionValue(this.womanNozzlePos); //切换到妇洗喷嘴位置
              this.updateWaterPressureValue(this.womanWaterGage); //切换到妇洗水压
              break;
            case 102: //喷嘴自洁模式
              this.setMode(6, true);
              break;
            // case 104: //104-舒适坐浴
            //   this.setMode(7, true);
            //   this.updateSprayPositionValue(this.hipNozzlePosition); //切换到臀洗喷嘴位置
            //   this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
            //   break;
          }
        }
      } else if (data.sid === "toiletStatus") {
        //马桶的当前状态
        if (data.data.status !== undefined) {
          console.log(
            "updateUI(): toiletStatus: data.data.status = ",
            data.data.status
          );
          switch (data.data.status) {
            // case 0: //待机中
            //   this.coverPlateStatus = false;
            //   this.seatRingStatus = false;

            //   this.coverOpening = false;
            //   this.coverClosing = false;
            //   this.ringOpening = false;
            //   this.ringClosing = false;
            //   break;
            case 1: //上电初始化
            case 3: //上电初始化
            case 4: //停止待机
            case 5: //停止进行中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 6: //喷嘴自洁中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 7: //暖风中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 8: //臀洗中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 9: //妇洗中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 10: //助便强洗中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 11: //舒适坐浴中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 12: //强弱按摩中?
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 13: //宽幅强洗中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 14: //臀洗移动中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 15: //妇洗移动中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 16: //助便强洗移动中
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            // case 17: //坐浴移动中
            //   this.coverPlateStatus = false;
            //   this.seatRingStatus = false;

            //   this.coverOpening = false;
            //   this.coverClosing = false;
            //   this.ringOpening = false;
            //   this.ringClosing = false;
            // case 100: //助便强洗中
            //   this.coverPlateStatus = false;
            //   this.seatRingStatus = false;

            //   this.coverOpening = false;
            //   this.coverClosing = false;
            //   this.ringOpening = false;
            //   this.ringClosing = false;
            //   break;
            // case 101: //冲水中
            //   this.coverPlateStatus = false;
            //   this.seatRingStatus = false;

            //   this.coverOpening = false;
            //   this.coverClosing = false;
            //   this.ringOpening = false;
            //   this.ringClosing = false;
            //   break;
            // case 102: //自动臀洗中
            //   this.coverPlateStatus = false;
            //   this.seatRingStatus = false;

            //   this.coverOpening = false;
            //   this.coverClosing = false;
            //   this.ringOpening = false;
            //   this.ringClosing = false;
            //   break;
            // case 103: //已着坐
            //   this.coverPlateStatus = false;
            //   this.seatRingStatus = false;

            //   this.coverOpening = false;
            //   this.coverClosing = false;
            //   this.ringOpening = false;
            //   this.ringClosing = false;
            //   break;
            // case 104: //助便移动中
            //   break;
            // case 105: //自动妇洗中
            //   break;
            case 100: //开盖中
              this.coverPlateStatus = true;
              this.seatRingStatus = false;

              this.coverOpening = true;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;

              this.cover = true;
              break;
            case 101: //关盖中
              this.coverPlateStatus = true;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = true;
              this.ringOpening = false;
              this.ringClosing = false;

              this.cover = false;
              break;
            case 102: //开圈中
              this.coverPlateStatus = false;
              this.seatRingStatus = true;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = true;
              this.ringClosing = false;

              this.ring = true;
              break;
            case 103: //关圈中
              this.coverPlateStatus = false;
              this.seatRingStatus = true;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = true;

              this.ring = false;
              break;
            case 104: //开盖开圈中
              this.coverPlateStatus = true;
              this.seatRingStatus = true;

              this.coverOpening = true;
              this.coverClosing = false;
              this.ringOpening = true;
              this.ringClosing = false;

              this.cover = true;
              this.ring = true;
              break;
            case 105: //关盖关圈中
              this.coverPlateStatus = true;
              this.seatRingStatus = true;

              this.coverOpening = false;
              this.coverClosing = true;
              this.ringOpening = false;
              this.ringClosing = true;

              this.cover = false;
              this.ring = false;
              break;
            case 106: //发泡中
              break;
            // case 112: //发泡中
            //   break;
            // case 113: //光照理疗中
            //   break;
            // case 114: //除臭中
            //   break;
            // case 115: //喷嘴拆卸中
            //   break;
            case 200: //自动臀洗
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
            case 201: //自动妇洗
              this.coverPlateStatus = false;
              this.seatRingStatus = false;

              this.coverOpening = false;
              this.coverClosing = false;
              this.ringOpening = false;
              this.ringClosing = false;
              break;
          }
        }
      } else if (data.sid === "wideWash") {
        //宽幅强洗开关
        if (data.data.on !== undefined) {
          this.wideWash = data.data.on === 1;
          // this.wideWash = true;//测试用，要删除
        }
      } else if (data.sid === "moveWash") {
        //移动按摩开关
        if (data.data.on !== undefined) {
          this.moveWash = data.data.on === 1;
          // this.moveWash = true;//测试用，要删除
        }
      } else if (data.sid === "smallflushSwitch") {
        //小冲开关
        if (data.data.on !== undefined) {
          this.smallFlush = data.data.on === 1;
          if (this.smallFlush) {
            this.stopBubbleTimer();
          }
        }
      } else if (data.sid === "bigflushSwitch") {
        //大冲开关
        if (data.data.on !== undefined) {
          this.flush = data.data.on === 1;
          if (this.flush) {
            this.stopBubbleTimer();
          }
        }
      } else if (data.sid === "seatRing") {
        //翻圈状态（不在翻圈中才更新，避免按钮闪烁）
        if (!this.seatRingStatus) {
          if (data.data.on !== undefined) {
            this.ring = data.data.on === 1;
          }
        }
      } else if (data.sid === "filpSwitch") {
        //翻盖状态（不在翻盖中才更新，避免按钮闪烁）
        if (!this.coverPlateStatus) {
          if (data.data.on !== undefined) {
            this.cover = data.data.on === 1;
          }
        }
      } else if (data.sid === "windGear") {
        //风温档位
        if (data.data.gear !== undefined) {
          this.updateWindTemperatureValue(data.data.gear);
        }
      } else if (data.sid === "waterGear") {
        //水温档位
        if (data.data.gear !== undefined) {
          this.updateWaterTemperatureValue(data.data.gear);
        }
      } else if (data.sid === "seatGear") {
        //座温档位
        if (data.data.gear !== undefined) {
          this.updateSeatTemperatureValue(data.data.gear);
        }
      } else if (data.sid === "filterElement") {
        // console.log("updateUI: 更新filterElement");
        //滤芯耗材服务:剩余百分比
        if (data.data.leftPercentage !== undefined) {
          // console.log("updateUI: leftPercentage = " + data.data.leftPercentage);
          this.filterLeftPer = data.data.leftPercentage;
          if (this.filterLeftPer <= 5) {
            //滤芯不足提醒
            this.faultList.remindCode = 1;
          } else {
            //去除滤芯不足提醒
            if (this.faultList.remindCode === 1) {
              this.faultList.remindCode = 0;
            }
          }
        }
        //滤芯耗材服务：滤芯等级
        if (data.data.filterType !== undefined) {
          // console.log("updateUI: 更新filterType");
          this.filterLevel = data.data.filterType;
        }
      } else if (data.sid === "tStatus") {
        //缓存盖板状态
        if (data.data.coverPlate !== undefined) {
          this.coverCache = data.data.coverPlate === 1;
        }
        //缓存坐圈状态
        if (data.data.seatRing !== undefined) {
          this.ringCache = data.data.seatRing === 1;
        }
        // 翻盖动作状态：1动作中，0已停止
        if (data.data.coverPlateStatus !== undefined) {
          this.coverPlateStatus = data.data.coverPlateStatus === 1;
          console.log(
            "updateUI(): tStatus: data.data.coverPlateStatus = ",
            data.data.coverPlateStatus
          );
        }
        // 翻圈动作状态：1动作中，0已停止
        if (data.data.seatRingStatus !== undefined) {
          this.seatRingStatus = data.data.seatRingStatus === 1;
          console.log(
            "updateUI(): tStatus: data.data.seatRingStatus = ",
            data.data.seatRingStatus
          );
        }
        // if (this.coverPlateStatus && !this.seatRingStatus) {
        //   //翻盖中
        //   if (!this.uiIsLocking) {
        //     this.cover = !this.cover;
        //   }
        // } else if (!this.coverPlateStatus && this.seatRingStatus) {
        //   //翻圈中
        //   if (!this.uiIsLocking) {
        //     this.ring = !this.ring;
        //   }
        // } else if (this.coverPlateStatus && this.seatRingStatus) {
        //   //盖圈一起翻中
        //   if (!this.uiIsLocking) {
        //     this.cover = !this.cover;
        //     this.ring = !this.ring;
        //   }
        // }
        // 发泡剂余量(泡沫盾液面)
        if (data.data.magicBubbleLevel !== undefined) {
          this.foamLeftState = data.data.magicBubbleLevel;
          if (this.foamLeftState === 3) {
            //发泡剂用尽
            this.faultList.remindCode = 2;
          } else if (this.foamLeftState === 1) {
            //发泡剂余量不足
            this.faultList.remindCode = 3;
          } else {
            if (
              this.faultList.remindCode === 2 ||
              this.faultList.remindCode === 3
            ) {
              this.faultList.remindCode = 0;
            }
          }
        }
        //出水状态
        if (data.data.waterEffluent !== undefined) {
          this.waterEffluent = data.data.waterEffluent === 1;
        }
        //水位状态 0-未加满 1-已加满
        if (data.data.waterLevel !== undefined) {
          this.waterLevel = data.data.waterLevel === 1;
        }

        // if (this.autoMode) {
        //   this.setMode(1, this.autoMode);
        //   // this.updateSprayPositionValue(this.hipNozzlePosition);
        //   // this.updateWaterPressureValue(this.hipWaterGage);
        // } else {
        //   if (this.autoModeWarnWind) {
        //     this.warmWindMode = true;
        //   }
        //   this.autoModeHipWash = false; //自动模式的臀洗阶段
        //   this.autoModeWideWash = false; //自动模式的宽幅强洗阶段
        //   this.autoModeWomanWash = false; //自动模式的妇洗阶段
        //   this.autoModeMoveWash = false; //自动模式的移动按摩阶段
        //   this.autoModeWarnWind = false; //自动模式的烘干阶段
        // }
      } else if (data.sid === "control") {
        //用户1
        if (data.data.user1 !== undefined) {
          this.user1 = data.data.user1;
        }
        //用户2
        if (data.data.user2 !== undefined) {
          this.user2 = data.data.user2;
        }
        //光照理疗开关
        if (data.data.phototherapy !== undefined) {
          this.lightTreatMode = data.data.phototherapy;
          switch (this.lightTreatMode) {
            case 1:
              this.redLightMode = true;
              this.blueLightMode = false;
              this.mixLightMode = false;
              break;
            case 2:
              this.redLightMode = false;
              this.blueLightMode = true;
              this.mixLightMode = false;
              break;
            case 3:
              this.redLightMode = false;
              this.blueLightMode = false;
              this.mixLightMode = true;
              break;
            default:
              this.redLightMode = false;
              this.blueLightMode = false;
              this.mixLightMode = false;
              break;
          }
        }
        //加液盒按钮开关
        if (data.data.filingBox !== undefined) {
          this.fillingBox = data.data.filingBox === 1;
        }
        //魔力泡按钮开关
        if (data.data.magicFoaming !== undefined) {
          this.magicBubble = data.data.magicFoaming === 1;
        }
        //更新魔力泡倒计时
        if (this.magicBubble) {
          this.startBubbleTimer();
        }
        //暖风移动
        if (data.data.warmMove !== undefined) {
          this.warmMove = data.data.warmMove === 1;
        }
        //喷嘴拆卸
        if (data.data.nozzleDisassembly !== undefined) {
          this.sprayDisassemble = data.data.nozzleDisassembly === 1;
        }
        //疏通模式
        if (data.data.dredging !== undefined) {
          this.dredgeMode = data.data.dredging === 1;
        }
        //喷嘴自洁开关
        if (data.data.cleaningSwitch !== undefined) {
          //喷嘴自洁关闭时，要开启无法点击的定时器
          // if (this.sprayWash && data.data.cleaningSwitch !== 1) {
          //   this.startSprayWashTimer();
          // }
          // if (data.data.cleaningSwitch === 1) {
          //   this.setMode(6, data.data.cleaningSwitch === 1);
          // } else {
          //   this.sprayWash = false;
          // }
          // this.sprayWash = data.data.cleaningSwitch === 1;
        }
      } else if (data.sid === "toiletGear") {
        //妇洗喷嘴位置
        if (data.data.womanNozzlePos !== undefined) {
          this.womanNozzlePos = data.data.womanNozzlePos;
          if (this.womanMode || this.autoWomanMode) {
            this.updateSprayPositionValue(this.womanNozzlePos);
          }
        }
        //臀洗喷嘴位置
        if (data.data.hipNozzlePos !== undefined) {
          this.hipNozzlePosition = data.data.hipNozzlePos;
          if (this.hipMode || this.autoHipMode || this.strongMode) {
            this.updateSprayPositionValue(this.hipNozzlePosition);
          }
        }
        // 妇洗水压
        if (data.data.womanWaterGage !== undefined) {
          this.womanWaterGage = data.data.womanWaterGage;
          if (this.womanMode || this.autoWomanMode) {
            this.updateWaterPressureValue(this.womanWaterGage);
          }
        }
        // //臀洗水压
        if (data.data.hipWaterGage !== undefined) {
          this.hipWaterGage = data.data.hipWaterGage;
          if (this.hipMode || this.autoHipMode || this.strongMode) {
            this.updateWaterPressureValue(this.hipWaterGage);
          }
        }
        //风速档位
        if (data.data.windSpeed !== undefined) {
          this.updateWindSpeedValue(data.data.windSpeed);
        }
        //宽幅幅度
        if (data.data.wideWashingRange !== undefined) {
          this.updateMoveRangeValue(data.data.wideWashingRange);
        }
        // //红光光照时长
        // if (data.data.redLight !== undefined) {
        //   this.redLightDuration = data.data.redLight;
        // }
        // //蓝光光照时长
        // if (data.data.blueLight !== undefined) {
        //   this.blueLightDuration = data.data.blueLight;
        // }
        // //除臭时长
        // if (data.data.deodorizationDuration !== undefined) {
        //   this.deodorizationDuration = data.data.deodorizationDuration;
        // }
        // //定时除臭（每隔多久时间除臭一次）
        // if (data.data.regularDeodorization !== undefined) {
        //   this.regularDeodorization = data.data.regularDeodorization;
        // }
        // //定点除臭时钟（定义每天的几点除臭，要与订单除臭分钟配合使用）：0-23
        // if (data.data.deodorizationHour !== undefined) {
        //   this.deodorizationHour = data.data.deodorizationHour;
        // }
        // //定点除臭分钟（定义每天的某个时点的第几分钟除臭，要与电动除臭时钟配合使用）：0-59
        // if (data.data.deodorizationMin !== undefined) {
        //   this.deodorizationMin = data.data.deodorizationMin;
        // }
      } else if (data.sid === "deviceAlarm") {
        //告警
        if (data.data.code !== undefined) {
          this.faultList.warnCode = data.data.code;
          // this.faultList.warnCode = 5;//测试用，要删除 流量异常告警
          // if (this.faultList.faultCode > 0 || this.faultList.warnCode > 0) {
          //   this.isShowFault = true;
          // } else {
          //   this.isShowFault = false;
          // }
          this.getWarmWindTipPosition();
        }
      } else if (data.sid === "faultDetection") {
        //故障
        if (data.data.code !== undefined) {
          this.faultList.faultCode = data.data.code;
          // this.faultList.faultCode = 1;//测试用，要删除 座圈传感器故障
          // if (this.faultList.faultCode > 0 || this.faultList.warnCode > 0) {
          //   this.isShowFault = true;
          // } else {
          //   this.isShowFault = false;
          // }
          this.getWarmWindTipPosition();
        }
      } else if (data.sid === "setting") {
        //四季温感
        if (data.data.tempSensor !== undefined) {
          this.seasonTempOpen = data.data.tempSensor;
        }
      }
    },

    //只更新翻盖翻圈中、发泡、着座等少数状态
    updateCoverOrRingPlateUI: function () {
      console.log("点击开关盖圈3秒后，只更新少数状态");
      if (this.tStatusData != null) {
        if (this.tStatusData.sid === "tStatus") {
          // 翻盖动作状态：1动作中，0已停止
          if (this.tStatusData.data.coverPlateStatus !== undefined) {
            this.coverPlateStatus =
              this.tStatusData.data.coverPlateStatus === 1;
            // console.log("只更新翻盖翻圈中状态UI：启动翻盖中", "coverPlateStatus = ", this.coverPlateStatus);
          }
          // 翻圈动作状态：1动作中，0已停止
          if (this.tStatusData.data.seatRingStatus !== undefined) {
            this.seatRingStatus = this.tStatusData.data.seatRingStatus === 1;
            // console.log("只更新翻盖翻圈中状态UI：启动翻圈中", "seatRingStatus = ", this.seatRingStatus);
          }
        }
      }
      if (this.controlData != null) {
        if (this.controlData.sid === "control") {
          //发泡开关
          //魔力泡按钮开关
          if (this.controlData.data.magicFoaming !== undefined) {
            this.magicBubble = this.controlData.data.magicFoaming === 1;
            console.log(
              "点击开关盖圈3秒后，只更新少数状态：魔力泡状态：",
              this.magicBubble
            );
          }
        }
      }
      if (this.seatStatusData != null) {
        if (this.seatStatusData.sid === "seatStatus") {
          //着坐状态
          if (this.seatStatusData.data.status !== undefined) {
            this.seatStatus = this.seatStatusData.data.status === 1;
            console.log(
              "点击开关盖圈3秒后，只更新少数状态：着座状态：",
              this.seatStatus
            );
          }
        }
      }
    },

    //只更新宽幅强洗状态
    updateWideWashUI: function () {
      if (this.wideWashData != null) {
        if (this.wideWashData.sid === "wideWash") {
          if (this.tStatusData.data.on !== undefined) {
            if (this.tStatusData.data.on === 1) {
              //宽幅强洗
              this.wideWash = true;
              this.updateWaterPressureValue(this.hipWaterGage); //切换到臀洗水压
            }
          }
        }
      }
    },

    //跳转到鸿蒙默认的设置页面
    gotoSetting: function () {
      jumpToSetting();
    },
    //跳转到自定义的功能设置页面
    gotoFuncSetting: function () {
      this.$router.push({
        path: "/setting",
        query: {
          deviceName: this.deviceName, //传递设备名参数
          roomName: this.roomName, //传递房间名参数
        },
      });
    },
    //跳转到自定义的功能设置页面
    gotoDeodorizeSetting: function () {
      this.$router.push({
        path: "/deodorizeSetting",
        query: {
          editType: "光触媒除臭设置页", //传递参数
        },
      });
    },
    //关闭页面
    closeMainPage: function () {
      console.log("路由：", this.$route.name);
      if (this.$route.name === "MainPage") {
        finishDeviceActivity();
      }
    },
    //跳转到发泡剂页面
    gotoFoam: function () {
      this.$router.push({
        path: "/foam",
        query: {
          editType: "发泡剂", //传递标题参数
        },
      });
    },
    //弹框：更多设置
    openMoreDialog(index) {
      this.moreDialogVisible = true;
    },
    //更多设置弹框菜单点击事件1
    clickUpdateHardware() {
      console.log("点击固件升级");
    },
    //更多设置弹框菜单点击事件2
    clickConfirm() {
      console.log("点击了confirm");
    },
    //双击或多击的延时处理
    isFasterClick() {
      if (this.hasClick) {
        // this.showToast(this.$i18n.t('toast.fastClick'));
        return true;
      } else {
        this.hasClick = true;
        setTimeout(() => {
          this.hasClick = false;
        }, 1000);
        return false;
      }
    },
    sliderVal(min, max, total) {},
    showToast(msg) {
      if (this.getOS() === "iOS") {
        this.$toast(msg); //自定义的toast
        // toast(1000, msg);//华为提供的toast，iOS版会导致显示后不自动消失,一直显示在屏幕上
      } else {
        toast(1000, msg);
      }
    },
    //更改暗黑模式
    changeDarkMode(themeName) {
      //标题栏、滚动栏等的样式（各页面统一配置）
      this.changeThemeDarkMode(themeName);
      //MainPage页面的样式
      this.changeMainPageDarkMode(themeName);
    },

    changeThemeDarkMode(themeName) {
      // 找到:root下所有定义以--current变量
      const currentCssVar = Array.from(document.styleSheets).reduce(
        (acc, sheet) =>
          (acc = [
            ...acc,
            ...Array.from(sheet.cssRules).reduce(
              (def, rule) =>
                (def =
                  rule.selectorText === ":root"
                    ? [
                        ...def,
                        ...Array.from(rule.style).filter((name) =>
                          name.startsWith("--current")
                        ),
                      ]
                    : def),
              []
            ),
          ]),
        []
      );
      currentCssVar.forEach((item) => {
        document.documentElement.style.setProperty(
          item,
          `var(--${themeName}${item.substring(9)})`
        );
      });
    },
    changeMainPageDarkMode(themeName) {
      // 找到:root下所有定义以--current变量
      const currentCssVar = Array.from(document.styleSheets).reduce(
        (acc, sheet) =>
          (acc = [
            ...acc,
            ...Array.from(sheet.cssRules).reduce(
              (def, rule) =>
                (def =
                  rule.selectorText === ":main"
                    ? [
                        ...def,
                        ...Array.from(rule.style).filter((name) =>
                          name.startsWith("--current")
                        ),
                      ]
                    : def),
              []
            ),
          ]),
        []
      );
      currentCssVar.forEach((item) => {
        document.documentElement.style.setProperty(
          item,
          `var(--${themeName}${item.substring(9)})`
        );
      });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.mainPageUserDialog {
  width: 100%;
  /* background: #00ff00; */
}

.mainPageUserDialog .titleContainer {
  width: 100%;
  height: 56px;
  /* background: #ff0000; */
  display: flex;
  flex-direction: row;
  align-items: center;
}

.mainPageUserDialog .titleContainer .title {
  font-size: 20px;
  color: var(--current-primary-color);
}

.mainPageUserDialog .funcBtnContainer {
  width: 100%;
  height: auto;
  margin-top: 8px;
  margin-bottom: 8px;
  /* background: #00ff00; */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mainPageUserDialog .funcBtnContainer:active {
  opacity: 0.3;
}

.mainPageUserDialog .funcBtnContainer .title {
  font-size: 16px;
  color: var(--current-primary-color);
}

.mainPageUserDialog .funcBtnContainer .content {
  font-size: 14px;
  color: var(--current-second-title-color);
  margin-top: 2px;
}

.mainPageUserDialog .cancelBtnContainer {
  height: 56px;
  width: 100%;
  display: flex;
  flex-direction: column;
  /* background: #00ff00; */
}

.mainPageUserDialog .cancelBtnContainer:active {
  opacity: 0.3;
}

.mainPageUserDialog .cancelBtnContainer .cancelBtn {
  width: 100%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 16px;
  color: var(--current-second-title-select-color);
  /* background: #ff0000; */
}

.mainPageUserDialog .lineContainer {
  width: 100%;
  height: 0.25px;
  display: flex;
  flex-direction: row;
  background: var(--current-divider-line-color);
}

.warmWindCardContainer {
  flex: 1;
  display: flex;
  height: 100%;
  /* border-radius: 16px;
  background-color: var(--current-card-background-color); */
  flex-direction: column;
}

/* 耗材 */
.consumeMaterial {
  width: 100%;
  padding-top: 4px;
  padding-bottom: 4px;
  background: var(--current-card-background-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
}
</style>
